diff --git a/src/components/AppLayout.tsx b/src/components/AppLayout.tsx index 63aebcb..f3b4f56 100644 --- a/src/components/AppLayout.tsx +++ b/src/components/AppLayout.tsx @@ -144,9 +144,11 @@ export function AppLayout() { const current = NAV.find(n => pathname.startsWith(n.to)) // Nav groups stay closed unless they hold the current page; a click on the label overrides that until the next route. const [toggled, setToggled] = useState>>({}) - useEffect(() => setToggled({}), [pathname]) + useEffect(() => { setToggled({}) }, [pathname]) // The window scrolls, not
, so a new page would open at the last page's scroll position. - useLayoutEffect(() => window.scrollTo(0, 0), [pathname]) + // In braces: Chrome's scrollTo now returns a Promise, which React would keep as the effect's + // cleanup and call on the next route change ("is not a function"), unmounting the whole app. + useLayoutEffect(() => { window.scrollTo(0, 0) }, [pathname]) const [collapsed, setCollapsed] = useState(readCollapsed) const toggleCollapsed = () => setCollapsed(c => { try { localStorage.setItem(COLLAPSED_KEY, c ? '0' : '1') } catch { /* keep it for this visit only */ }