From 8828a87407363a113c158f6b9ffdcdf59e40ab19 Mon Sep 17 00:00:00 2001 From: Ever Date: Fri, 13 Feb 2026 10:22:02 -0600 Subject: [PATCH] fix: wrong navbar height on 404 pages --- src/components/Navbar.tsx | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index 225cacbf..0a48eefc 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -198,22 +198,21 @@ export function Navbar({ children }: { children: React.ReactNode }) { const containerRef = React.useRef(null) React.useEffect(() => { - const updateContainerHeight = () => { - if (containerRef.current) { - const height = containerRef.current.offsetHeight + const el = containerRef.current + if (!el) return + + const observer = new ResizeObserver((entries) => { + for (const entry of entries) { + const height = entry.borderBoxSize?.[0]?.blockSize ?? el.offsetHeight document.documentElement.style.setProperty( '--navbar-height', `${height}px`, ) } - } + }) - updateContainerHeight() // Initial call to set the height - - window.addEventListener('resize', updateContainerHeight) - return () => { - window.removeEventListener('resize', updateContainerHeight) - } + observer.observe(el) + return () => observer.disconnect() }, []) const [showMenu, setShowMenu] = React.useState(false)