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