diff --git a/.changeset/stupid-balloons-change.md b/.changeset/stupid-balloons-change.md new file mode 100644 index 0000000000..98c40b4d60 --- /dev/null +++ b/.changeset/stupid-balloons-change.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-techdocs': patch +--- + +Bug fix on sidebar position when Tab-Bar is enabled diff --git a/plugins/techdocs/src/reader/components/Reader.tsx b/plugins/techdocs/src/reader/components/Reader.tsx index a67443e40f..7bcf182d56 100644 --- a/plugins/techdocs/src/reader/components/Reader.tsx +++ b/plugins/techdocs/src/reader/components/Reader.tsx @@ -89,12 +89,17 @@ export const Reader = ({ entityId, onReady }: Props) => { useEffect(() => { const updateSidebarPosition = () => { if (!!shadowDomRef.current && !!sidebars) { + const mdTabs = shadowDomRef.current!.querySelector( + '.md-container > .md-tabs', + ); sidebars!.forEach(sidebar => { const newTop = Math.max( shadowDomRef.current!.getBoundingClientRect().top, 0, ); - sidebar.style.top = `${newTop}px`; + sidebar.style.top = mdTabs + ? `${newTop + mdTabs.getBoundingClientRect().height}px` + : `${newTop}px`; }); } }; @@ -318,8 +323,11 @@ export const Reader = ({ entityId, onReady }: Props) => { // set sidebar height so they don't initially render in wrong position const docTopPosition = (dom as HTMLElement).getBoundingClientRect() .top; + const mdTabs = dom.querySelector('.md-container > .md-tabs'); sideDivs!.forEach(sidebar => { - sidebar.style.top = `${docTopPosition}px`; + sidebar.style.top = mdTabs + ? `${docTopPosition + mdTabs.getBoundingClientRect().height}px` + : `${docTopPosition}px`; }); }, }),