Skip to content

Commit 14821ae

Browse files
authored
Fix MAUI RoutedViewHost Navigation (#3692)
<!-- Please be sure to read the [Contribute](https://github.com/reactiveui/reactiveui#contribute) section of the README --> **What kind of change does this PR introduce?** <!-- Bug fix, feature, docs update, ... --> Bug fix **What is the current behavior?** <!-- You can also link to an open issue here. --> #3640 When 'RoutedViewHost' is activated, it calls 'SyncNavigationStacksAsync', which pushes a page for the current ViewModel. However, the Router.Navigate subscription is also triggered, creating and pushing a new page for the same ViewModel. **What is the new behavior?** <!-- If this is a feature change --> To fix this, I filtered Navigate to execute the action only when the NavigationStacks have different sizes, since it seems that is what the Navigate subscription was supposed to do anyway. I think this makes the subsequent call to SyncNavigationStacksAsync() useless. Should I remove it? **What might this PR break?** RoutedViewHost Navigate subscription. **Please check if the PR fulfills these requirements** - [ ] Tests for the changes have been added (for bug fixes / features) - [ ] Docs have been added / updated (for bug fixes / features) **Other information**: I was informed that there were no tests for MAUI and no documentation seemed to be present either.
1 parent f533f16 commit 14821ae

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/ReactiveUI.Maui/RoutedViewHost.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public RoutedViewHost()
7676

7777
Router?
7878
.Navigate
79+
.Where(_ => Navigation.NavigationStack.Count != Router.NavigationStack.Count)
7980
.ObserveOn(RxApp.MainThreadScheduler)
8081
.SelectMany(_ => PagesForViewModel(Router.GetCurrentViewModel()))
8182
.SelectMany(async page =>

0 commit comments

Comments
 (0)