Skip to content

Commit

Permalink
fix(ObjectPage): add safeguards for single section spacer calculation (
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas742 authored Mar 19, 2024
1 parent f3625ed commit f01d47c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/main/src/components/ObjectPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -468,18 +468,18 @@ const ObjectPage = forwardRef<HTMLDivElement, ObjectPagePropTypes>((props, ref)
const objectPage = objectPageRef.current;
const sectionNodes = objectPage.querySelectorAll<HTMLDivElement>('[id^="ObjectPageSection"]');
const lastSectionNode = sectionNodes[sectionNodes.length - 1];
const tabContainerContainer = tabContainerContainerRef.current;

const observer = new ResizeObserver(([sectionElement]) => {
const subSections = lastSectionNode.querySelectorAll<HTMLDivElement>('[id^="ObjectPageSubSection"]');
const lastSubSection = subSections[subSections.length - 1];
const lastSubSectionOrSection = lastSubSection ?? sectionElement.target;

if ((currentTabModeSection && !lastSubSection) || (sectionNodes.length === 1 && !lastSubSection)) {
setSectionSpacer(0);
} else {
} else if (!!tabContainerContainer) {
setSectionSpacer(
objectPage.getBoundingClientRect().bottom -
tabContainerContainerRef.current.getBoundingClientRect().bottom -
tabContainerContainer.getBoundingClientRect().bottom -
lastSubSectionOrSection.getBoundingClientRect().height -
TAB_CONTAINER_HEADER_HEIGHT
);
Expand Down

0 comments on commit f01d47c

Please sign in to comment.