-
Notifications
You must be signed in to change notification settings - Fork 2k
Shell.OnNavigated not called for route navigation #34662
Copy link
Copy link
Labels
area-controls-shellShell Navigation, Routes, Tabs, FlyoutShell Navigation, Routes, Tabs, Flyoutpartner/syncfusionIssues / PR's with Syncfusion collaborationIssues / PR's with Syncfusion collaborationplatform/iospotential-regressionThis issue described a possible regression on a currently supported version., verification pendingThis issue described a possible regression on a currently supported version., verification pendingregressed-in-10.0.50s/triagedIssue has been reviewedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering TriageVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't workingSomething isn't working
Milestone
Description
Metadata
Metadata
Assignees
Labels
area-controls-shellShell Navigation, Routes, Tabs, FlyoutShell Navigation, Routes, Tabs, Flyoutpartner/syncfusionIssues / PR's with Syncfusion collaborationIssues / PR's with Syncfusion collaborationplatform/iospotential-regressionThis issue described a possible regression on a currently supported version., verification pendingThis issue described a possible regression on a currently supported version., verification pendingregressed-in-10.0.50s/triagedIssue has been reviewedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering TriageVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't workingSomething isn't working
Type
Fields
Give feedbackNo fields configured for issues without a type.
Description
On 10.0.50 and above, the
Shell.OnNavigated(ShellNavigatedEventArgs args)method is not invoked when a navigation is triggered using theShell.Current.GoToAsyncmethod.In my company's app, we register a number of our pages using
AddTransientWithShellRoutefromCommunityToolkit.Maui(e.g.AddTransientWithShellRoute<MyPage, MyViewModel>(), which adds a route called "MyPage" for that page). Our app's shell is a subclass ofShellnamedAppShell.When we need to navigate, we call
await Shell.Current.GoToAsync("MyPage", ...)to navigate to the correct page. On 10.0.41, this navigation causes ourAppShellclass'sOnNavigatedmethod to be called once the navigation is performed. We use this to handle post-navigation events.On 10.0.50 and above,
OnNavigatedis no longer called for such navigations on iOS. It works fine on Android. Our app does not target Mac Catalyst, so I am unsure if this bug also occurs there.I have traced this to the
IShellController.UpdateCurrentStateimplementation in Shell.cs:maui/src/Controls/src/Core/Shell/Shell.cs
Lines 984 to 999 in 720a9d4
After the navigation occurs,
result?.LocationandoldState?.Locationboth hold the same value (the old page), so it never callsHandleNavigated.For example, after signing in, the app changes the shell's
CurrentItemto one of the root items - suppose this item has a route of/RootItem/RootContent. The user can select an item on this root page that will result inawait Shell.Current.GoToAsync("MyPage", ...).Once this navigation occurs,
UpdateCurrentStateis called, and bothresult?.LocationandoldState?.Locationevaluate to/RootItem/RootContent, instead of what I would expect to see, which would beresult?.Locationevaluating to/MyPage.Steps to Reproduce
Routing.RegisterRoute)Shell.Current.GoToAsyncOnNavigatedin the shell class, and print a debug statement when it is calledOnNavigatedis not called.Link to public reproduction project repository
No response
Version with bug
10.0.50
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
10.0.40
Affected platforms
iOS
Affected platform versions
No response
Did you find any workaround?
No response
Relevant log output