diff --git a/src/layouts/PublicLayout.tsx b/src/layouts/PublicLayout.tsx index 684908a..7d70149 100644 --- a/src/layouts/PublicLayout.tsx +++ b/src/layouts/PublicLayout.tsx @@ -349,6 +349,12 @@ export function PublicLayout() { useEffect(() => { if (!open) return; + // Opening the menu from the burger also closes the search overlay, whose + // scroll-lock cleanup fires a programmatic scroll. Ignore scroll-to-close + // for a brief window so that restore scroll doesn't shut the menu we just + // opened; genuine user scrolls afterwards still close it. + const openedAt = Date.now(); + const closeOnOutside = (event: MouseEvent | TouchEvent) => { const target = event.target as Node; if ( @@ -360,7 +366,10 @@ export function PublicLayout() { } setOpen(false); }; - const closeOnScroll = () => setOpen(false); + const closeOnScroll = () => { + if (Date.now() - openedAt < 250) return; + setOpen(false); + }; document.addEventListener("mousedown", closeOnOutside); document.addEventListener("touchstart", closeOnOutside);