You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Saving then loading restores the wrong position when the current page also appears earlier in history #54
NavigationState<T>.FromNavigationStack (Navigation/Models/NavigationState.cs, ~line 63) rebuilds the current index with FindIndex(item => item.Id == current.Id), which returns the first entry with that Id. When a page appears twice in history (Home → About → Home), the saved index points at the first Home.
Repro
With InMemoryPersistenceProvider: navigate to Home, About, then a new NavigationItem("home", "Home"). Save, then LoadStateAsync() into a new Navigation.
before save: count=3 canBack=True canFwd=False back=[Home,About]
after load: count=3 canBack=False canFwd=True back=[] fwd=[About,Home]
Expected: the state after load matches the state before save.
Reproduced against the current main build.
Why it matters
Revisiting a page is the normal case in navigation (returning to Home, a dashboard, or a list view). After a restart the user lands at the start of their history, Back is disabled, and Forward replays pages they had already left.
Suggested fix
Save the real index instead of searching for it:
Expose it through INavigation<T>, for example a CurrentIndex property, and use it in FromNavigationStack.
Without an interface change: GetBackStack().Count gives the index when Current is not null, since the back stack is _items.Take(_currentIndex).
Acceptance criteria
The repro restores canBack=True, canFwd=False, back=[Home,About].
Next steps: Save the real index. Either use GetBackStack().Count, which avoids an interface change, or expose CurrentIndex on INavigation<T>. Add a regression test that navigates Home → About → Home, saves, loads, and asserts CanGoBack, CanGoForward and the back stack.
Activity
matt-edmondson commentedon Sep 26, 2026
Triage
NavigationState<T>.FromNavigationStack, which looks up the index withFindIndex. Maintainer: @matt-edmondson.NavigationStateround trip). Once LoadStateAsync with JsonFilePersistenceProvider always throws InvalidOperationException, so saved navigation can never be restored #53 is fixed, JSON users will hit this bug too, so fixing both together is recommended.GetBackStack().Count, which avoids an interface change, or exposeCurrentIndexonINavigation<T>. Add a regression test that navigates Home → About → Home, saves, loads, and assertsCanGoBack,CanGoForwardand the back stack.Generated by Claude Code