Skip to content

Conversation

@bijington
Copy link
Contributor

@bijington bijington commented Jul 8, 2025

Description of Change

This PR introduces a workaround to swallow any touches on our internal Border control to avoid the touches rippling through to the background BoxView.

Linked Issues

This is more of a workaround than a fix but it does solve the issue for now

PR Checklist

Additional information

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a workaround for an Android-specific issue where taps on the box view behind the popup border still trigger the underlying gesture. It adds an empty TapGestureRecognizer to the PopupBorder to absorb taps.

  • Prevents propagation of background taps through the popup on Android
  • Adds an empty TapGestureRecognizer to PopupBorder
Comments suppressed due to low confidence (2)

src/CommunityToolkit.Maui/Views/Popup/PopupPage.shared.cs:205

  • Consider adding a UI test to verify that this workaround prevents taps on Android from propagating to underlying elements, ensuring this behavior is covered and preventing regressions.
			PopupBorder.GestureRecognizers.Add(new TapGestureRecognizer());

src/CommunityToolkit.Maui/Views/Popup/PopupPage.shared.cs:204

  • Expand this comment to include a TODO referencing issue #2795 and clarify that this workaround should be removed once the underlying MAUI bug is fixed.
			// Currently .NET MAUI allows for the TapGestureRecognizer added to the BoxView behind this Border to be triggered with a tap on Android.

@TheCodeTraveler
Copy link
Collaborator

TheCodeTraveler commented Jul 8, 2025

Have you tried toggling InputTransparent to prevent the touch from being delivered through the Popup?

@bijington
Copy link
Contributor Author

Have you tried toggling InputTransparent to prevent the touch from being delivered through the Popup?

I did stick a breakpoint in the code and saw that it was set to false on the Border which made me believe it wouldn't make a difference

@Stedy59
Copy link

Stedy59 commented Jul 10, 2025

Have you tried toggling InputTransparent to prevent the touch from being delivered through the Popup?

I did stick a breakpoint in the code and saw that it was set to false on the Border which made me believe it wouldn't make a difference

Why not just check if the touch point is inside the border bounds? Placing a TapGestureRecognizer just to mitigate the issue will lead to other issues... Like potential nested Gesture Recognizes.

@bijington
Copy link
Contributor Author

Have you tried toggling InputTransparent to prevent the touch from being delivered through the Popup?

I did stick a breakpoint in the code and saw that it was set to false on the Border which made me believe it wouldn't make a difference

Why not just check if the touch point is inside the border bounds? Placing a TapGestureRecognizer just to mitigate the issue will lead to other issues... Like potential nested Gesture Recognizes.

Nice idea! I have included this in the PR now. It is more involved but I think it provides a clearer intent. @TheCodeTraveler what do you think?

@TheCodeTraveler TheCodeTraveler changed the title Workaround .NET MAUI touch based behaviour Prevent Popup From Being Dismissed when Tapped Inside Popup Jul 11, 2025
@TheCodeTraveler
Copy link
Collaborator

Genius!! We should've been using this all along 💯

popupPageLayout.PopupBorder.Bounds.Contains(position.Value)

@Stedy59
Copy link

Stedy59 commented Jul 11, 2025

Genius!! We should've been using this all along 💯

popupPageLayout.PopupBorder.Bounds.Contains(position.Value)

I am glad that I could help... MANY more from where this came from.

Take a look at a couple...

https://www.linkedin.com/feed/update/urn:li:activity:7269824678708318208/
https://www.linkedin.com/feed/update/urn:li:activity:7272978239122284545/

@TheCodeTraveler TheCodeTraveler merged commit 652eb1b into main Jul 11, 2025
11 checks passed
@TheCodeTraveler TheCodeTraveler deleted the feature/sl-patch-tap-gesture branch July 11, 2025 18:35
@bijington
Copy link
Contributor Author

@TheCodeTraveler good follow up with removing the BoxView

@github-actions github-actions bot locked and limited conversation to collaborators Jul 13, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] PopupV2 CanBeDismissedByTappingOutsideOfPopup=true still dismisses the popup if tap INSIDE the popup

3 participants