-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Fix for OnAppearing of Page called again, although this page was on already replaced NavigationStack #25596
base: main
Are you sure you want to change the base?
Conversation
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue25089.cs
Outdated
Show resolved
Hide resolved
/rebase |
773116e
to
1e0840f
Compare
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
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 you use a unit test instead of a UITest for this one?
@PureWeen, we couldn't recreate the same UI test scenario in the unit test case because the Shell.Current is always null when try to navigate to another page by using Shell.Current.GoToAsync().
|
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.
Use the shell instance you instantiated vs Shell.Current
await newShell.GoToAsync("modalPage1", true);
await newShell.GoToAsync("//modalPage2", true);
await newShell.GoToAsync("//windowPage", true);
@PureWeen, We are unable to recreate the same UI test scenario in the unit test case because the Appearing event is not triggered when navigating from one ShellContent page to another. As a result, we cannot maintain the appearing count in the test case.
|
The sample code you have here isn't quite correct. Having a Route named "modalPage1" and a shell content named "modalPage1" isn't going to operate correctly. if you look at |
@PureWeen, I have added the unit test case based on your suggestion for the scenario. Could you please share any further suggestions. |
…ing` only if the page is visible.
… case is executed on all platforms, including Mac Catalyst.
|
||
|
||
[Fact] | ||
public async Task VerifyPageAppearingSequence2() // Temporary Name |
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.
Fixed the shell content so if it's created as a template it creates correctly and life cycle events all fire.
I also added this test to demonstrate an issue with the code added for this fixed.
I think the fix for this one is going to need to be moved into PresentedPageAppearing
Root cause
The issue occurs because the ShellSection.SendAppearing() method triggers PresentedPageAppearing() even when PresentedPage doesn’t match CurrentItem. This mismatch causes the OnAppearing() logic of the previous page to execute at the wrong time, resulting in unintended behavior.
Description of Issue Fix
The fix involves adding the IsPageVisible method to contain the logic for determining if the presented page is the current item. The SendAppearing method was updated to ensure that PresentedPageAppearing is called only if the page is visible, correcting the invocation logic and preventing unintended behavior.
Tested the behavior in the following platforms.
Issues Fixed
Fixes #25089
Output
BeforeFix-OnAppearing.mp4
AfterFix-OnAppearing.mp4