Skip to content

fix(maui): make RoutedViewHost match the router stack after a reset - #4569

Merged
glennawatson merged 1 commit into
mainfrom
fix/maui-routed-view-host-reset-stack
Nov 27, 2026
Merged

glennawatson merged 1 commit into
mainfrom
fix/maui-routed-view-host-reset-stack

Conversation

@glennawatson

Copy link
Copy Markdown
Contributor

Summary

The MAUI RoutedViewHost now makes its page stack match Router.NavigationStack exactly.

  • After NavigateAndReset, the pages beneath the new page are removed, so no back button appears.
  • When the page stack is built from the router, pages are inserted in router order. Before, a router stack of two or more gave a duplicate root page.
  • Pages at the bottom of the stack that already show the right view model are kept, so matching pages are not rebuilt.

Why

SyncNavigationStacksAsync always kept NavigationStack[0] as its root. After NavigateAndReset from a login page, the router held only the home view model, but the page stack stayed [Login, Home]. The sync also inserted pages for Router[0..n-2] before a root page that was already Router[0].

Refs #4220 (discussion)

Breaking changes

None

How this was verified

  • Added NavigateAndReset_RemovesThePagesBeneathTheNewPage and SyncNavigationStacks_EmptyPageStack_BuildsPagesInRouterOrder. Both fail on main and pass with this change.
  • dotnet test for ReactiveUI.Maui.Tests passes on net10.0 and net11.0 (416 tests).

Checklist

  • I have read the Contribute guide
  • The PR title follows Conventional Commits
  • Tests cover this change, or the summary says why they do not
  • New or changed public API has XML documentation

- Remove pages beneath the current page that the router no longer holds.
- Build missing pages in router order instead of duplicating the root.
- Add tests for NavigateAndReset and for syncing a three-page stack.
@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.93%. Comparing base (3e097c0) to head (b845956).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4569      +/-   ##
==========================================
- Coverage   94.93%   94.93%   -0.01%     
==========================================
  Files         184      184              
  Lines        6086     6085       -1     
  Branches      728      729       +1     
==========================================
- Hits         5778     5777       -1     
  Misses        308      308              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@glennawatson
glennawatson merged commit c5b66ca into main Nov 27, 2026
20 of 21 checks passed
@glennawatson
glennawatson deleted the fix/maui-routed-view-host-reset-stack branch November 27, 2026 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant