From c2c5fd81d4047eae2acba32159d8999b23b69a55 Mon Sep 17 00:00:00 2001 From: Silberengel Date: Tue, 11 Nov 2025 12:24:49 +0100 Subject: [PATCH] fix navigation --- src/PageManager.tsx | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/PageManager.tsx b/src/PageManager.tsx index a497ff5..5572388 100644 --- a/src/PageManager.tsx +++ b/src/PageManager.tsx @@ -625,8 +625,13 @@ export function PageManager({ maxStackSize = 5 }: { maxStackSize?: number }) { const needScrollToTop = page === currentPrimaryPage // Clear any primary note view when navigating to a new primary page + // This ensures menu clicks always take you to the primary page, not stuck on overlays setPrimaryNoteView(null) + // Always clear secondary pages when navigating to a primary page via menu + // This ensures clicking menu items always takes you to that page, not stuck on profile/note pages + clearSecondaryPages() + // Update primary pages and current page setPrimaryPages((prev) => { const exists = prev.find((p) => p.name === page) @@ -647,13 +652,6 @@ export function PageManager({ maxStackSize = 5 }: { maxStackSize?: number }) { if (needScrollToTop) { PRIMARY_PAGE_REF_MAP[page].current?.scrollToTop('smooth') } - - // Always clear secondary pages when navigating to home (escape hatch behavior) - if (page === 'home') { - clearSecondaryPages() - } else if (isSmallScreen) { - clearSecondaryPages() - } } @@ -710,7 +708,12 @@ export function PageManager({ maxStackSize = 5 }: { maxStackSize?: number }) { const clearSecondaryPages = () => { if (secondaryStack.length === 0) return - window.history.go(-secondaryStack.length) + // Capture the length before clearing + const stackLength = secondaryStack.length + // Clear the state immediately for instant navigation + setSecondaryStack([]) + // Also update browser history to keep it in sync + window.history.go(-stackLength) } if (isSmallScreen) {