Skip to content

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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

KarthikRajaKalaimani
Copy link
Contributor

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.

  • Android
  • Windows
  • iOS
  • Mac

Reference:

N/A

Issues Fixed:

Fixes #19168

Screenshots

Before After
Screen.Recording.2025-06-19.at.3.46.23.PM.mov
Screen.Recording.2025-06-19.at.3.44.26.PM.mov

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Jun 19, 2025
Copy link
Contributor

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.

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Jun 19, 2025

_tapGestureRecognizer = new UITapGestureRecognizer(() =>
{
picker.EndEditing(true);
Copy link
Contributor

@bhavanesh2001 bhavanesh2001 Jun 19, 2025

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.

Copy link
Contributor Author

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;
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@KarthikRajaKalaimani KarthikRajaKalaimani marked this pull request as ready for review June 19, 2025 13:14
@KarthikRajaKalaimani KarthikRajaKalaimani requested a review from a team as a code owner June 19, 2025 13:14
@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

#elif IOS
App.Tap("Button");
#endif
VerifyScreenshot();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pending snapshot on Mac:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pending snapshot on Mac: image

I have added the Mac snapshot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-picker Picker community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[regression/8.0.3] iOS Picker dismiss does not work when clicking outside of the Picker
3 participants