-
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
Fixed Net 8: Page and control Unloaded events firing on iOS when navigating to another page #25852
base: main
Are you sure you want to change the base?
Conversation
Hey there @NirmalKumarYuvaraj! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
App.Click("ButtonId"); | ||
App.WaitForElement("ButtonId"); | ||
App.Click("ButtonId"); | ||
VerifyScreenshot(); |
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.
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.
@jsuarezruiz , I have added the pending snapshots.
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
Issue Details:
On the iOS platform, the Loaded and Unloaded events of the current page are triggered twice when navigating to another page.
Root Cause:
The MovedToWindow method in the MauiView class is called twice when page navigation occurs with animation enabled. This behavior causes the _movedToWindow event to be repeatedly wired and unwired, which sequentially triggers the Loaded and Unloaded events.
Description of Change:
To resolve the issue, I moved the UnloadedCheck and OnLoadedCheck methods to the UI thread. This change ensures that calls are queued on the UI thread, allowing the Loaded and Unloaded events to trigger correctly once the UIView is attached to a window. Additionally, I removed redundant code for wiring the Loaded and Unloaded events, as the MovedToWindow method will handle these triggers for all MauiView instances upon attachment to and detachment from the window, with the events firing directly from _movedToWindow
Tested the behaviour in the following platforms.
Reference
https://stackoverflow.com/questions/34484518/willmovetowindow-is-called-twice
Issues Fixed
Fixes #21916
Screenshots
Before Issue Fix
before.2.mov
After Issue Fix
after.2.mov