Add BoxView behind the Popup content to safely handle touch interaction#2997
Add BoxView behind the Popup content to safely handle touch interaction#2997TheCodeTraveler merged 8 commits intomainfrom
Conversation
There was a problem hiding this comment.
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 |
samples/CommunityToolkit.Maui.Sample/Views/Popups/CollectionViewPopup.xaml
Outdated
Show resolved
Hide resolved
samples/CommunityToolkit.Maui.Sample/ViewModels/Views/Popup/CollectionViewPopupViewModel.cs
Outdated
Show resolved
Hide resolved
…tyToolkit/Maui into feature/sl-fix-popup-interaction
|
@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. |
|
The fix is in the latest version which targets .NET 10 so you will need Xcode 26. |
|
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. |
|
No worries. I'm pretty happy with the result of the PR so hopefully it'll merge soon |
…/CommunityToolkit/Maui into feature/sl-fix-popup-interaction
TheCodeTraveler
left a comment
There was a problem hiding this comment.
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. |
|
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. |
Description of Change
This PR reverts the changes within this commit 51e996b to bring back a hidden
BoxViewthat makes it possible to safely handle touch interactions when handling the dismiss of popup.The sample application includes deliberate styling targeted at a
BoxViewto highlight that this should now avoid inheriting any styling in developers apps.This is also an alternative fix to #2871
Linked Issues
PR Checklist
approved(bug) orChampioned(feature/proposal)mainat time of PRAdditional information