From 14821ae2a16d9173b3abc93f7c3c877106a09158 Mon Sep 17 00:00:00 2001 From: iuri dotta Date: Wed, 6 Dec 2023 22:10:10 -0300 Subject: [PATCH] Fix MAUI RoutedViewHost Navigation (#3692) **What kind of change does this PR introduce?** Bug fix **What is the current behavior?** #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?** 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. --- src/ReactiveUI.Maui/RoutedViewHost.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ReactiveUI.Maui/RoutedViewHost.cs b/src/ReactiveUI.Maui/RoutedViewHost.cs index bffebeb44c..1ee1ce70a9 100644 --- a/src/ReactiveUI.Maui/RoutedViewHost.cs +++ b/src/ReactiveUI.Maui/RoutedViewHost.cs @@ -76,6 +76,7 @@ public RoutedViewHost() Router? .Navigate + .Where(_ => Navigation.NavigationStack.Count != Router.NavigationStack.Count) .ObserveOn(RxApp.MainThreadScheduler) .SelectMany(_ => PagesForViewModel(Router.GetCurrentViewModel())) .SelectMany(async page =>