-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fixed NavigationPage and FlyoutPage both call OnNavigatedTo, so it is called twice #31931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
{ | ||
App.WaitForElement("Go to Third Page"); | ||
App.Tap("ThirdPageButton"); | ||
await Task.Delay(300); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Include a comment explaining it, waiting to navigation animations to complete.
|
||
internal void SendNavigatedTo(NavigatedToEventArgs args) | ||
{ | ||
if (HasNavigatedTo) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this blocks OnNavigatedTo after the first call, even when navigating away and back to the page? (NavigationPage, TabbedPage, FlyoutPage).
|
||
[Test] | ||
[Category(UITestCategories.Navigation)] | ||
public async Task Issue23902NavigationTest() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can include more tests?
I would like to verify Re-Navigation cases:
OnNavigatedToCalledAgainOnReNavigation
. Navigate to PageA, navigate back, then navigate to PageA again. OnNavigatedTo should be called twice (once per navigation TO the page). Expected: NavigatedTo count = 2OnNavigatedToCalledAgainOnReFlyoutNavigation
. Same using a FluyoutPage.
|
||
internal void SendNavigatedTo(NavigatedToEventArgs args) | ||
{ | ||
if (HasNavigatedTo) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this blocks OnNavigatedTo after the first call, even when navigating away and back to the page? (NavigationPage, TabbedPage, FlyoutPage).
Issue Details:
On Android, the OnNavigatedTo method of the content page is being called twice when Detail page of FlyoutPage is navigation page.
Root Cause:
The duplicate invocation occurs due to two separate triggers:
i) Setting the Detail property of the FlyoutPage explicitly calls OnNavigatedTo.
ii) The OnHandlerChangedCore method also triggers OnNavigatedTo. This method is invoked from the overridden OnFragmentResumed in StackNavigationManager, which is itself called from the native Android framework during the fragment lifecycle.
As a result, both the framework-level and platform-level calls cause OnNavigatedTo to execute, leading to the observed duplication.
Description of Change:
To prevent duplicate calls, the OnNavigatedTo method is not invoked again if the same page has already been navigated to. This check is handled within the SendNavigatedTo method of the Page class.
Tested the behavior in the following platforms.
Reference:
N/A
Issues Fixed:
Fixes #23902
Screenshots
Screen.Recording.2025-10-09.at.11.25.36.AM.mov
Screen.Recording.2025-10-09.at.11.22.43.AM.mov