Add closing process when tapping the outer area of Popup#2081
Merged
Conversation
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.
This PR resolves the issue where the Popup cannot be closed when the CanBeDismissedByTappingOutsideOfPopup property is true and you tap an area within 10px around the Popup.
Description of Change
Dialog, which is the base of Popup, has areas around it that do not respond to taps on Android.
Handle the touch event and intentionally call the Popup's close process when the outside of the Popup is tapped.
Below are the changes.
[src\CommunityToolkit.Maui.Core\Views\Popup\MauiPopup.android.cs]
The above code calls the OnDismissedByTappingOutsideOfPopup method when the tapped coordinates are outside the Popup.
The return value of OnTouchEvent is separated by an If statement, because if you call OnDismissedByTappingOutsideOfPopup, MauiPopup will be disposed of, and an ObjectDisposedException will occur when base.OnTouchEvent(e) is called.
I didn't know how to write it smartly.
If there is a smarter way to write it, could you please refactor it.
Linked Issues
PR Checklist
approved(bug) orChampioned(feature/proposal)mainat time of PRAdditional information
Below are the verification results.
To make it easier to see where the taps are, I turned on "Show taps" in the Android developer options.
[CanBeDismissedByTappingOutsideOfPopup : true]
Android.Emulator.-.pixel_5_-_api_33_5554.2024-08-01.14-02-27.mp4
[CanBeDismissedByTappingOutsideOfPopup : false]
Android.Emulator.-.pixel_5_-_api_33_5554.2024-08-01.13-58-59.mp4
If the CanBeDismissedByTappingOutsideOfPopup property is true, you can see that tapping within 10px around the Popup will close the Popup.