From 2aab54319ef7994403c98a479a572733714ae672 Mon Sep 17 00:00:00 2001 From: Adrian Ke Chongyang <14866712+adrianke77@users.noreply.github.com> Date: Mon, 22 Mar 2021 23:42:49 +0800 Subject: [PATCH] techdocs: reset scroll position on page navigate (#5018) Signed-off-by: Chongyang Adrian, Ke Co-authored-by: Chongyang Adrian, Ke --- .changeset/slimy-lies-tap.md | 5 +++++ plugins/techdocs/src/reader/components/Reader.tsx | 1 + 2 files changed, 6 insertions(+) create mode 100644 .changeset/slimy-lies-tap.md diff --git a/.changeset/slimy-lies-tap.md b/.changeset/slimy-lies-tap.md new file mode 100644 index 0000000000..8903f2e036 --- /dev/null +++ b/.changeset/slimy-lies-tap.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-techdocs': patch +--- + +TechDocs: links at sidebar and bottom reset scroll position to top diff --git a/plugins/techdocs/src/reader/components/Reader.tsx b/plugins/techdocs/src/reader/components/Reader.tsx index 984e310bfb..2231476869 100644 --- a/plugins/techdocs/src/reader/components/Reader.tsx +++ b/plugins/techdocs/src/reader/components/Reader.tsx @@ -113,6 +113,7 @@ export const Reader = ({ entityId, onReady }: Props) => { addLinkClickListener({ baseUrl: window.location.origin, onClick: (_: MouseEvent, url: string) => { + window.scroll({ top: 0 }); const parsedUrl = new URL(url); if (parsedUrl.hash) { history.pushState(