-
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
OnAppearing not triggered when going back from Modal page #8513
Comments
Verified, thanks for the attached sample and detailed steps. |
The same behavior occurs when you go back from a regular content page too. OnAppearing of the displayed page is not triggered. |
There is inconsistent usage of the HasAppeared property in Page. In FlyoutPage, TabbedPage and MultiPage it is used to store a reminder that the SendAppearing() call needs to be made at the appropriate time in the page lifecycle after a current page switch. However, in NavigationPage it is used as a state machine toggle to ensure an OnDisappearing must be made before another OnAppearing is fired. In NavigationPage line 406:
I don't believe this should be the same check for both functions, and the second should be checking the inverse ( HasAppeared == false ). When MauiNavigationImpl calls FireAppearing() in OnPopAsync() this check will fail, leaving the page in a broken state, causing both the OnAppearing not to fire and the ensuing OnDisappearing when the page leaves, as _hasAppeared doesn't get updated to True. Minimizing the App will correct the HasAppeared state, or firing a SendAppearing() on the destination Page in ModalPopping as a temp workaround. |
Is this going to be fixed anytime soon? |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
Why has this not the highest priority? My personal opinion:
At the moment, the problems i have with modal pages (i.e. multiple popups) and memory leaks in general, forced me to redesign my whole application and to move everything (pages and view models) to singletons. Now it's even more important, to have reliable lifecycle events, to manage the state of the view models. All i want, since december 2021, is to publish a MAUI application, which looks acceptable and does not crash when it's used for more than 5 minutes. |
@rachelkang @samhouts hi - very grateful if you could confirm that this fix also applies to OnNavigatedTo and will be part of the next Visual studio release.. Or if not can this be part of @PureWeen https://github.com/PureWeen/ShanedlerSamples.. this kind of critical.. Many thanks |
Hello lovely human, thank you for your comment on this issue. Because this issue has been closed for a period of time, please strongly consider opening a new issue linking to this issue instead to ensure better visibility of your comment. Thank you! |
OnAppearing dotnet/maui#8513, fixed in latest versions. Cleanup of messy code and added early returns
Description
OnAppearing is not triggered when going back from Modal page.
Steps to Reproduce
Download solution here
BugMauiModal.zip
Run solution
On MainPage, click on button to go the Second page
Go back with "Back button" located on navigation bar
On MainPage, label should display "Appeared 2" --> OK
On MainPage, click on button to go the Second page
From SecondPage, click on "Open modal" button
On modal page, click on "Close" button
On second page, abel should display "Appeared 2" but it displays "Appeared 1 time"--> Not OK
Mean, OnAppearing was not triggered in this case
Version with bug
6.0.400 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android 11
Did you find any workaround?
N/A
Relevant log output
No response
The text was updated successfully, but these errors were encountered: