-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fixed the Picker didn't dismiss it when tapping outside on iOS and MacCatalyst platform. #30067
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
Hey there @@KarthikRajaKalaimani! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
|
||
_tapGestureRecognizer = new UITapGestureRecognizer(() => | ||
{ | ||
picker.EndEditing(true); |
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.
Strong reference to platform view in gesture handler is asking for trouble.
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.
Strong reference to platform view in gesture handler is asking for trouble.
Thanks for the suggestion. I have corrected it.
{ | ||
picker.EndEditing(true); | ||
}); | ||
_tapGestureRecognizer.CancelsTouchesInView = false; |
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.
CancelsTouchesInView = false
lets taps through, but this gesture may dismiss the picker before "Done" is tapped, which can prevent selection from committing, please verify.
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.
Tested this scenario and confirmed that it works as expected — the SelectedItem property retains its value when tapping outside the Picker.
/azp run MAUI-UITests-public |
Azure Pipelines successfully started running 1 pipeline(s). |
#elif IOS | ||
App.Tap("Button"); | ||
#endif | ||
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.
Issue Details:
Tapping outside the Picker does not dismiss it on iOS and Mac, whereas it works as expected on Android and Windows.
Root Cause:
The touch handling for taps outside the picker was not implemented, which is why the picker was not being dismissed as expected on iOS and Mac platform.
Description of Change:
To resolve this issue, a tap gesture recognizer was added to the window containing the Picker. This allows the system to detect taps outside the Picker and dismiss it appropriately. The gesture recognizer is added during the OnStarted event and properly removed and disposed of in the OnEnded event and Disconnect methods. This implementation has been applied and successfully verified on both iOS and macOS platforms.
Tested the behavior in the following platforms.
Reference:
N/A
Issues Fixed:
Fixes #19168
Screenshots
Screen.Recording.2025-06-19.at.3.46.23.PM.mov
Screen.Recording.2025-06-19.at.3.44.26.PM.mov