From 2a4a3b32dd3c9267f3d6df9f8e5a09880c5d2185 Mon Sep 17 00:00:00 2001 From: Adrian Ke Date: Tue, 6 Jul 2021 16:45:39 +0800 Subject: [PATCH] techdocs: sidebars not adjusting positions Signed-off-by: Adrian Ke --- .changeset/techdocs-stale-lies-greet.md | 5 +++++ plugins/techdocs/src/reader/components/Reader.tsx | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/techdocs-stale-lies-greet.md diff --git a/.changeset/techdocs-stale-lies-greet.md b/.changeset/techdocs-stale-lies-greet.md new file mode 100644 index 0000000000..8c9ad63a3c --- /dev/null +++ b/.changeset/techdocs-stale-lies-greet.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-techdocs': patch +--- + +Techdocs: fix sidebars not adjusting position automatically diff --git a/plugins/techdocs/src/reader/components/Reader.tsx b/plugins/techdocs/src/reader/components/Reader.tsx index f80cf6cc4c..480a783f2c 100644 --- a/plugins/techdocs/src/reader/components/Reader.tsx +++ b/plugins/techdocs/src/reader/components/Reader.tsx @@ -82,10 +82,10 @@ export const Reader = ({ entityId, onReady }: Props) => { useEffect(() => { updateSidebarPosition(); - window.addEventListener('scroll', updateSidebarPosition); + window.addEventListener('scroll', updateSidebarPosition, true); window.addEventListener('resize', updateSidebarPosition); return () => { - window.removeEventListener('scroll', updateSidebarPosition); + window.removeEventListener('scroll', updateSidebarPosition, true); window.removeEventListener('resize', updateSidebarPosition); }; // an update to "state" might lead to an updated UI so we include it as a trigger