terry-staging #11
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user