Skip to content

Comments

Add BoxView behind the Popup content to safely handle touch interaction#2997

Merged
TheCodeTraveler merged 8 commits intomainfrom
feature/sl-fix-popup-interaction
Dec 11, 2025
Merged

Add BoxView behind the Popup content to safely handle touch interaction#2997
TheCodeTraveler merged 8 commits intomainfrom
feature/sl-fix-popup-interaction

Conversation

@bijington
Copy link
Contributor

Description of Change

This PR reverts the changes within this commit 51e996b to bring back a hidden BoxView that makes it possible to safely handle touch interactions when handling the dismiss of popup.

The sample application includes deliberate styling targeted at a BoxView to highlight that this should now avoid inheriting any styling in developers apps.

This is also an alternative fix to #2871

Linked Issues

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

Copilot AI review requested due to automatic review settings December 9, 2025 20:32
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 reverts to using a BoxView overlay behind popup content to safely handle touch interactions when dismissing popups. This approach resolves issues where tap gestures on the popup page itself were unreliable, especially when interacting with controls like CollectionView inside the popup.

Key changes:

  • Reintroduced a transparent BoxView (PopupOverlay) as the background layer for tap detection
  • Moved tap gesture handling from the page level to the overlay level within PopupPageLayout
  • Added a new CollectionViewPopup sample to demonstrate the fix

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/CommunityToolkit.Maui/Views/Popup/PopupPage.shared.cs Added PopupOverlay class and refactored PopupPageLayout to handle tap gestures on the overlay instead of the page
samples/CommunityToolkit.Maui.Sample/Views/Popups/CollectionViewPopup.xaml New XAML popup showcasing CollectionView with selection inside a popup
samples/CommunityToolkit.Maui.Sample/Views/Popups/CollectionViewPopup.xaml.cs Code-behind for the CollectionView popup sample
samples/CommunityToolkit.Maui.Sample/ViewModels/Views/Popup/CollectionViewPopupViewModel.cs ViewModel for handling CollectionView selection and popup dismissal
samples/CommunityToolkit.Maui.Sample/Pages/Views/Popup/PopupsPage.xaml.cs Added handler to show the new CollectionView popup
samples/CommunityToolkit.Maui.Sample/Pages/Views/Popup/PopupsPage.xaml Added button to trigger CollectionView popup demo
samples/CommunityToolkit.Maui.Sample/Resources/Styles/Styles.xaml Added BoxView style to demonstrate that popup overlay doesn't inherit app styles
samples/CommunityToolkit.Maui.Sample/MauiProgram.cs Registered CollectionViewPopup with its ViewModel in DI container

@CliffAgius CliffAgius self-assigned this Dec 9, 2025
CliffAgius
CliffAgius previously approved these changes Dec 9, 2025
Copy link
Contributor

@CliffAgius CliffAgius left a comment

Choose a reason for hiding this comment

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

Looking over this I can't see any issues and it seems to run in the sample app here but only able to test Android at the moment.

@bijington
Copy link
Contributor Author

@MichaelShapiro are you happy to test the artefacts of this PR once we sort the actions? This should solve your issue

@MichaelShapiro
Copy link

@MichaelShapiro are you happy to test the artefacts of this PR once we sort the actions? This should solve your issue

be happy to test if it doesn't require updating to xcode26.

@bijington
Copy link
Contributor Author

The fix is in the latest version which targets .NET 10 so you will need Xcode 26.

@MichaelShapiro
Copy link

This is what i thought. Unfortunately, testing on my side at this time won't be possible right away; hardware limitations :( So sorry for that.

@bijington
Copy link
Contributor Author

No worries. I'm pretty happy with the result of the PR so hopefully it'll merge soon

Copilot AI review requested due to automatic review settings December 11, 2025 20:53
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@bijington bijington enabled auto-merge (squash) December 11, 2025 21:03
@TheCodeTraveler TheCodeTraveler changed the title Revert back to a BoxView behind the Popup content to safely handle touch interaction Add BoxView behind the Popup content to safely handle touch interaction Dec 11, 2025
Copilot AI review requested due to automatic review settings December 11, 2025 21:14
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Collaborator

@TheCodeTraveler TheCodeTraveler left a comment

Choose a reason for hiding this comment

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

Thanks Shaun. Approved!

I went ahead and fixed the WindowsRT compiler error and the failing unit tests for you.

I also fixed the // Clean up Popup Resources section to clear the BoxView.TapGestureRecognizers

@TheCodeTraveler TheCodeTraveler merged commit 960d0b5 into main Dec 11, 2025
10 checks passed
@TheCodeTraveler TheCodeTraveler deleted the feature/sl-fix-popup-interaction branch December 11, 2025 21:31
@bijington
Copy link
Contributor Author

Thanks Shaun. Approved!

I went ahead and fixed the WindowsRT compiler error and the failing unit tests for you.

I also fixed the // Clean up Popup Resources section to clear the BoxView.TapGestureRecognizers

Thanks Brandon. In future thought let's please resort to reviews and the author doing the work as I have previously suggested.

@TheCodeTraveler
Copy link
Collaborator

TheCodeTraveler commented Dec 13, 2025

Please check the build status next time.

The Windows build was failing with the WinRT compiler error and the macOS build wasn't completing due to the failing unit tests.

I would hope you would've caught it as the author and I also hope that the reviewer who approved this PR would've caught it as well. Neither had, and it was an easy fix.

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

Labels

None yet

Projects

None yet

4 participants