Cleanup Popup Resources When Closed#2971
Merged
TheCodeTraveler merged 11 commits intoCommunityToolkit:mainfrom Nov 28, 2025
Merged
Cleanup Popup Resources When Closed#2971TheCodeTraveler merged 11 commits intoCommunityToolkit:mainfrom
TheCodeTraveler merged 11 commits intoCommunityToolkit:mainfrom
Conversation
The `OnNavigatedFrom` method in `PopupPage.shared.cs` has been updated to verify that the popup is actually closing before performing cleanup operations. The appropriate modal stack (`ModalStack`) is now used depending on whether `Shell` is present. This avoids unnecessarily cleaning up `GestureRecognizers` and unsubscribing from the `PropertyChanged` event, improving stability and preventing unexpected behavior.
Contributor
Author
|
@dotnet-policy-service agree |
TheCodeTraveler
previously approved these changes
Nov 28, 2025
Collaborator
TheCodeTraveler
left a comment
There was a problem hiding this comment.
Thanks @AlejoTorresLeon! Good catch that OnNavigatedFrom also fires when a second Popup is overlayed onto a visible Popup 🙌
Just FYI - I moved the cleanup of Popup resources out of PopupPage.OnNavigatedFrom() and into PopupPage.CloseAsync() to make things a bit cleaner and to avoid the modalStack.Contains(this) improving performance a bit.
Contributor
Author
|
@TheCodeTraveler Excellent observation, thank you very much. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
OnNavigatedFrommethod inPopupPage.shared.cshas been updated to verify that the popup is actually closing before performing cleanup operations. The appropriate modal stack (ModalStack) is now used depending on whetherShellis present. This avoids unnecessarily cleaning upGestureRecognizersand unsubscribing from thePropertyChangedevent, improving stability and preventing unexpected behavior.What this PR solves
Fixes an issue where Popup A cannot be dismissed by tapping outside when Popup B was opened and closed on top of it.
Root Cause
After Popup B closed, Popup A was not receiving inside/outside touch events correctly.
Solution
When Popup is shown via PopupExtensions, we ensure PopupPage receives the correct gesture handling and event routing.
Testing
Linked Issues
Fixes #2962