diff --git a/frontend/src/routes/+page.svelte b/frontend/src/routes/+page.svelte index b11cd05..dde7ee2 100644 --- a/frontend/src/routes/+page.svelte +++ b/frontend/src/routes/+page.svelte @@ -276,10 +276,11 @@ // The initial 'enter' is handled by onMount, after its data deps are fetched. afterNavigate((nav) => { if (nav.type === 'enter') return; - // Forward in-app nav deepens the stack; back/forward (popstate) unwinds it. - // Clamped at 0, so an out-of-app landing keeps Back app-safe (→ Highlights). + // Forward in-app nav deepens the stack; popstate moves by its signed delta + // (Back = -1, Forward = +1, ±N for jumps), so a back-then-forward dance keeps + // an accurate count. Clamped at 0, so an out-of-app landing stays app-safe. if (nav.type === 'goto' || nav.type === 'link') appNavDepth += 1; - else if (nav.type === 'popstate') appNavDepth = Math.max(0, appNavDepth - 1); + else if (nav.type === 'popstate') appNavDepth = Math.max(0, appNavDepth + (nav.delta ?? -1)); loadView(selected); });