Skip to content

Commit

Permalink
Prevent invalid height value of MainContent when using the `fullHeigh…
Browse files Browse the repository at this point in the history
…t` prop

Previously, `topPosition` could be `undefined`, causing the `height` to
be invalid because `calc()` contained the value `undefinedpx`.

This issue would occur on the page tree when clicking on a page and
then clicking the back button. The page tree's `MainContent` would
have a height of `0`.
  • Loading branch information
jamesricky committed Sep 5, 2023
1 parent 028462c commit 662abcc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .changeset/quiet-paws-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@comet/admin": patch
---

Prevent the `MainContent` component from having an invalid height.

This bug would cause the page tree to have no height when navigating into a page and then navigating back again.
2 changes: 1 addition & 1 deletion packages/admin/admin/src/mui/MainContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function Main({
classes,
}: MainContentProps & WithStyles<typeof styles>) {
const mainRef = React.useRef<HTMLElement>(null);
const topPosition = fullHeight ? mainRef.current?.offsetTop : 0;
const topPosition = fullHeight && mainRef.current ? mainRef.current.offsetTop : 0;

const rootClasses: string[] = [classes.root];
if (disablePaddingTop) rootClasses.push(classes.disablePaddingTop);
Expand Down

0 comments on commit 662abcc

Please sign in to comment.