Skip to content

Commit

Permalink
Correctly handle mobile menu closing
Browse files Browse the repository at this point in the history
Fixes #375
  • Loading branch information
Yoeori committed Aug 23, 2023
1 parent 1dc7d48 commit 977b6f6
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/components/page-header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@ export default function PageHeader({
closeRef,
isNotHamburgerMode,
);

const internalOnChangeVisible = () => {
const newVisible = !isMenuVisible;
onVisibleChange?.(newVisible);
setMenuVisible(newVisible);
};

useEffect(() => {
onVisibleChange?.(isMenuVisible);
}, [isMenuVisible, onVisibleChange]);

const LogoWrapper = homepage ? 'h1' : 'div';

Expand Down Expand Up @@ -69,7 +67,7 @@ export default function PageHeader({
aria-labelledby="menu-label"
aria-expanded={isMenuVisible}
aria-controls="menu-id"
onClick={() => internalOnChangeVisible()}
onClick={() => setMenuVisible(!isMenuVisible)}
>
<div
className={and(
Expand Down

0 comments on commit 977b6f6

Please sign in to comment.