Skip to content

Conversation

kramer-e
Copy link

@kramer-e kramer-e commented Sep 1, 2025

Description of Change

The TapGestureRecognizer to check for taps outside the popup hijacks the taps for inner (child) controls. Changed the TapGestureRecognizer to a PointerGestureRecognizer that does not block/intercept the tap gesture. The bug was introduced in this PR #2741 Tested on Android and iOS, the issue was only present on iOS.

Linked Issues

2852
2727

PR Checklist

  • Has a linked Issue, and the Issue has been approved(bug) or Championed (feature/proposal)
  • Has tests (if omitted, state reason in description)
  • Has samples (if omitted, state reason in description)
  • Rebased on top of main at time of PR
  • Changes adhere to coding standard
  • Documentation created or updated: https://github.com/MicrosoftDocs/CommunityToolkit/pulls

Additional information

Added CollectionView with selectable items to ComplexPopup to test tapping a CollectionView item within the Popup. When tapping an item, it sets the value of the ReturnText Entry.

@kramer-e
Copy link
Author

kramer-e commented Sep 1, 2025

@dotnet-policy-service agree

@bijington
Copy link
Contributor

Thank you for this, I haven't had a chance to test it but I am a little worried about the Microsoft documentation on this:

image

For some reason it doesn't claim to officially support iOS which either feels wrong from the docs or a potentially risky thing to include. Have you tested on iOS?

To follow-up with an additional question, is the PointerGestureRecognizer designed to not swallow the taps or is this just by chance? I haven't seen anything that explains either way but I'm just intrigued

@kramer-e
Copy link
Author

kramer-e commented Sep 1, 2025

As far as I can see, iOS is supported in code, I just tested it and gave the exact same coordinates as the TapGestureRecogniser. I think it is not fully supported, because there is no "hover" event on iOS dotnet/maui#9141

The funny thing is, that for Android PointerGestureRecognizer is officially is supported, but is broken because of a bug dotnet/maui#20849 I just tested it on Android and it does not return a coordinate when using PointerGestureRecognizer.

So, to get this working with both platforms, TapGestureRecognizer must be used for Android and PointerGestureRecognizer for iOS.

@kramer-e
Copy link
Author

kramer-e commented Sep 1, 2025

The PointerGestureRecogniser on iOS uses a custom implementation of the UIGestureRecognizer and is low level:
https://github.com/dotnet/maui/blob/936db46aa2c06c94b4eda7f288585c24b478d058/src/Controls/src/Core/Platform/GestureManager/GesturePlatformManager.iOS.cs#L410
This detects pointer entered/released and is not really tied to a specific UIView I think.

The TapGestureRecogniser on iOS uses UITapGestureRecognizer under the hood.
https://github.com/dotnet/maui/blob/936db46aa2c06c94b4eda7f288585c24b478d058/src/Controls/src/Core/Platform/GestureManager/GesturePlatformManager.iOS.cs#L482
So I guess there is more involved there to detect a tap/double tap and it is tied to a certain UIView, so more risk of the tap being swallowed by this implementation.

For detecting a tap outside of the Popup I would use the more low level PointerGestureRecogniser, because you only need the coordinates.

@bijington
Copy link
Contributor

Or perhaps we go back to the idea of placing a view behind that can handle the tap detection. BoxView caused styling issues but we could create our own PopupBackground class that would allow developers to style it if they wanted (although it would fight with PopupOptions). This would save dealing with the platform differences that you mentioned. What do you think?

@kramer-e
Copy link
Author

kramer-e commented Sep 2, 2025

I don't think styling the background will be needed in most usecases, having PageOverlayColor is good enough. Maybe it is also more complex, if you need to take safe-area's into account and it adds another layer in the UI. I updated my code to Popup v2 and hope this issue can be fixed soon, or use a workaround for the time being.

The Android PointerGestureRecognizer should be fixed soon* (I hope), so maybe that is an option.

Thanks for your help Shaun!

@dotnet-policy-service dotnet-policy-service bot added stale The author has not responded in over 30 days help wanted This proposal has been approved and is ready to be implemented labels Oct 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

help wanted This proposal has been approved and is ready to be implemented stale The author has not responded in over 30 days

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] CollectionView SelectionChanged event does not fire on toolkit:popup page unless held for 3 seconds, only on iOS and only with 12.2.0 update

3 participants