-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[Android, Windows] Fixed App.Current.PageDisappearing not raised when a page is popped #28998
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
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.
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (2)
src/Controls/src/Core/NavigationPage/NavigationPage.cs:786
- The change correctly fires the Disappearing event before the page is removed. Please verify that similar navigation flows (e.g., modal pops) have been adjusted consistently to avoid related issues.
Owner.FireDisappearing(currentPage);
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue14092.cs:16
- [nitpick] Consider renaming the test method to 'PageDisappearingEventTriggeredOnPop' to improve clarity and consistency with event naming.
public void PageDisAppearingTriggeredWhenPop()
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.
Won’t the same issue happen with PopToRoot
too?
maui/src/Controls/src/Core/NavigationPage/NavigationPage.cs
Lines 817 to 835 in 8e875b7
return Owner.SendHandlerUpdateAsync(animated, | |
() => | |
{ | |
var lastIndex = NavigationStack.Count - 1; | |
while (lastIndex > 0) | |
{ | |
var page = (Page)NavigationStack[lastIndex]; | |
Owner.RemoveFromInnerChildren(page); | |
lastIndex = NavigationStack.Count - 1; | |
pagesToRemove.Insert(0, page); | |
} | |
Owner.CurrentPage = newPage; | |
}, | |
() => | |
{ | |
Owner.SendNavigating(previousPage); | |
Owner.FireDisappearing(previousPage); | |
Owner.FireAppearing(newPage); | |
}, |
@bhavanesh2001 Yes, the same issue also occurs with PopToRoot. I’ve addressed it as well and included the fix in this PR. |
/azp run MAUI-UITests-public |
Azure Pipelines successfully started running 1 pipeline(s). |
Issue Detail
App.Current.PageDisappearing is not raised when a page is popped using PopAsync/PopToRootAsync
Root Cause
The navigation stack was not updated correctly when the Disappearing event was invoked. The page was removed from the stack before the event was triggered. Since the page was already removed, its parent was set to null, and as a result, the Disappearing event was not invoked.
Description of change
Modified the logic to trigger the Disappearing event before removing the page from the stack, which resolves the issue.
Reference
On iOS, Disappearing event is invoked first then the page is removed from the stack.
In PopModalAsync also, Disappearing invoked first then Removed from stack.
Attached is a reference showing the order of events before and after the fix.

Issues Fixed
Fixes #14092
Screenshots
14092Before1.mov
14092After1.mov