Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions src/components/FooterBar/FooterBar.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,23 @@

box-sizing: border-box;
width: 100vw;
padding-bottom: calc(var(--bleed) + env(safe-area-inset-bottom));
padding-bottom: var(--bleed);

&-content {
@include flex.row($gap: 1.5rem, $yAlign: center);

box-sizing: border-box;
margin: 0 auto;
padding-top: calc(var(--vertical-padding) - var(--border-width));
margin: calc(-1 * var(--border-width)) auto 0;
padding-top: var(--vertical-padding);
padding-right: calc(var(--page-padding) + env(safe-area-inset-right));
padding-bottom: var(--vertical-padding);
padding-bottom: calc(var(--vertical-padding) + env(safe-area-inset-bottom));
padding-left: calc(var(--page-padding) + env(safe-area-inset-left));

&[data-mobile] {
--mobile-offset: 0.5rem;
--mobile-padding-x: calc(var(--vertical-padding) + 0.5rem);

padding-right: calc(var(--vertical-padding) + var(--mobile-offset) + env(safe-area-inset-right));
padding-bottom: calc(var(--vertical-padding) + var(--mobile-offset));
padding-left: calc(var(--vertical-padding) + var(--mobile-offset) + env(safe-area-inset-left));
padding-right: calc(var(--mobile-padding-x) + env(safe-area-inset-right));
padding-left: calc(var(--mobile-padding-x) + env(safe-area-inset-left));
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/FooterBar/FooterBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export const FooterBar = ({
return;
}
const observer = new ResizeObserver(([entry]) => {
document.documentElement.style.setProperty('--footer-bar-height', `${entry.contentRect.height}px`);
const height = entry.borderBoxSize?.[0]?.blockSize ?? entry.target.getBoundingClientRect().height;
document.documentElement.style.setProperty('--footer-bar-height', `${height}px`);
Comment on lines +37 to +38

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Prevent shared --footer-bar-height from being cleared by the wrong instance.

This component writes a global CSS variable, but cleanup removes it unconditionally. With the default now 0, unmounting one FooterBar can collapse layout even if another FooterBar is still mounted. Track ownership (or active instance count) before removing the variable.

Suggested fix (instance-count guard)
+let activeFooterBars = 0;
+
 export const FooterBar = ({
   children,
   className,
   maxWidth = '100vw',
   mobile = false,
   portalTarget = document.body,
 }: FooterBarProps): ReactElement => {
   const contentRef = useRef<HTMLDivElement>(null);

   useEffect(() => {
+    activeFooterBars += 1;
     const content = contentRef.current;
     if (!content) {
       return;
     }
     const observer = new ResizeObserver(([entry]) => {
       const height = entry.borderBoxSize?.[0]?.blockSize ?? entry.target.getBoundingClientRect().height;
       document.documentElement.style.setProperty('--footer-bar-height', `${height}px`);
     });
     observer.observe(content);
     return () => {
       observer.disconnect();
-      document.documentElement.style.removeProperty('--footer-bar-height');
+      activeFooterBars -= 1;
+      if (activeFooterBars === 0) {
+        document.documentElement.style.removeProperty('--footer-bar-height');
+      }
     };
   }, []);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/FooterBar/FooterBar.tsx` around lines 37 - 38, The FooterBar
currently sets a global CSS var '--footer-bar-height' in the ResizeObserver
callback (in the FooterBar component) but unconditionally clears it on cleanup;
change this to track ownership so the variable is only removed when the last
FooterBar unmounts: add a module-level counter (e.g., footerBarInstanceCount)
that you increment when the component mounts and decrement in the cleanup, set
the CSS variable when the observer reports a height (same code:
entry.borderBoxSize?.[0]?.blockSize ??
entry.target.getBoundingClientRect().height) and only remove/reset
'--footer-bar-height' in the cleanup when footerBarInstanceCount reaches zero;
ensure all references are done inside the FooterBar component's effect/observer
lifecycle so other instances retain the variable while active.

});
observer.observe(content);
return () => {
Expand Down
2 changes: 1 addition & 1 deletion src/style/variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@
--app-bar-logo-size: 2.5rem;

// Footer Bar Sizes
--footer-bar-height: 4rem;
--footer-bar-height: 0;

// Spacing
--modal-padding: 1rem;
Expand Down
Loading