add height of md-tabs on sidebar position

Signed-off-by: Emre <m.emre.konar@gmail.com>
This commit is contained in:
Emre
2021-05-11 17:15:22 +02:00
parent f3f09dda34
commit a62cfe0682
2 changed files with 15 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-techdocs': patch
---
Bug fix on sidebar position when Tab-Bar is enabled
@@ -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`;
});
},
}),