diff --git a/src/layout/Shell.jsx b/src/layout/Shell.jsx index 9e1fb8b..ff0afc5 100644 --- a/src/layout/Shell.jsx +++ b/src/layout/Shell.jsx @@ -1,5 +1,5 @@ -import { useEffect, useState } from 'react' -import { NavLink, Outlet, useLocation } from 'react-router-dom' +import { useState } from 'react' +import { NavLink, Outlet } from 'react-router-dom' import { NAV_GROUPS, STAGES } from '../api/config.js' import { rolesOf, visibleStages } from '../api/permissions.js' import { useStageCounts } from '../api/portfolio.jsx' @@ -35,8 +35,10 @@ export default function Shell() { // because a menu that stays open over the page you just chose is a menu you // have to dismiss twice. Desktop never reads this — the rail is always there. const [navOpen, setNavOpen] = useState(false) - const { pathname } = useLocation() - useEffect(() => { setNavOpen(false) }, [pathname]) + // Closing on the link rather than on the route: a menu that stays open over + // the page you just chose is a menu you have to dismiss twice. Keyed off the + // anchor so opening the Closed fold — which is not navigation — leaves it up. + const closeIfLink = (e) => { if (e.target.closest('a')) setNavOpen(false) } const count = (s) => counts[s.uid] || { total: 0, waiting: 0, working: 0, urgent: 0 } @@ -92,7 +94,7 @@ export default function Shell() { {/* The scrim only exists while the drawer is open, and only on a phone: tapping the page you can see should put the menu away. */} {navOpen ?