Skip to content

Commit 4a8bca0

Browse files
gaearonclaude
andcommitted
Don't reopen the mobile menu on Back
The menu state became "open for this path", derived against the current pathname so the overlay disappears as soon as a navigation commits. But the path was never forgotten, so navigating Back to the page the menu was opened on brought the menu back with it. Clear it once the path changes. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent b91a253 commit 4a8bca0

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/components/Layout/TopNav/TopNav.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@ export default function TopNav({
169169
const [showSearch, setShowSearch] = useState(false);
170170
const [isScrolled, setIsScrolled] = useState(false);
171171
const scrollParentRef = useRef<HTMLDivElement>(null);
172+
// Deriving from the path hides the menu as soon as a navigation commits.
173+
// Forget the path afterwards, so going Back doesn't reopen the menu.
174+
if (openMenuPath !== null && openMenuPath !== asPath) {
175+
setOpenMenuPath(null);
176+
}
172177
const isMenuOpen = openMenuPath === asPath;
173178
const {breadcrumbs} = getRouteMeta(asPath, routeTree);
174179

0 commit comments

Comments
 (0)