-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Android] CollectionView selection with drag/drop gestures on Android - fix #32811
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
base: main
Are you sure you want to change the base?
Conversation
Added logic to allow event bubbling when only DragGestureRecognizer or DropGestureRecognizer are present, enabling CollectionView item selection to work correctly on Android. Includes new test case and UI test to verify the fix for issue dotnet#32702.
|
Hey there @@kubaflo! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
There was a problem hiding this 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 fixes a bug where CollectionView item selection doesn't work on Android when DragGestureRecognizer or DropGestureRecognizer is attached to item content. The fix modifies the touch event handling logic to allow event bubbling when only drag/drop gesture recognizers are present, enabling parent behaviors (like CollectionView selection) to function correctly.
Key Changes
- Modified
OnPlatformViewTouchedmethod to conditionally sete.Handled = falsebased on gesture recognizer types - Added
ShouldAllowEventBubbling()helper method to determine if event bubbling should be allowed - Created comprehensive UI test case to verify the fix
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/Controls/src/Core/Platform/GestureManager/GesturePlatformManager.Android.cs | Added logic to allow event bubbling when only drag/drop recognizers are present, enabling parent selection behavior |
| src/Controls/tests/TestCases.HostApp/Issues/Issue32702.xaml | Created XAML test page demonstrating CollectionView with drag/drop gestures on items |
| src/Controls/tests/TestCases.HostApp/Issues/Issue32702.xaml.cs | Implemented code-behind for test case with selection tracking |
| src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue32702.cs | Added UI test that verifies item selection works with drag/drop gestures |
| if (recognizers == null || recognizers.Count == 0) | ||
| return false; | ||
|
|
||
| // Don't allow bubbling if we other recognizers than drag and drop |
Copilot
AI
Nov 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grammatical error in comment. Should be 'if we have other recognizers' instead of 'if we other recognizers'.
| // Don't allow bubbling if we other recognizers than drag and drop | |
| // Don't allow bubbling if we have other recognizers than drag and drop |
| // Allow event bubbling when only drag/drop recognizers are present | ||
| // For other gestures, allow bubbling so parent behaviors (like item selection) work | ||
| if (ShouldAllowEventBubbling()) | ||
| { | ||
| e.Handled = false; | ||
| } |
Copilot
AI
Nov 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment on line 290 is confusing. It says 'For other gestures, allow bubbling' but the code actually prevents bubbling for other gestures (returns false in ShouldAllowEventBubbling when non-drag/drop recognizers are present). The comment should clarify that bubbling is allowed ONLY when drag/drop recognizers are present, not for other gestures.
| if (ShouldAllowEventBubbling()) | ||
| { | ||
| e.Handled = false; | ||
| } |
Copilot
AI
Nov 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic doesn't explicitly handle the case when ShouldAllowEventBubbling() returns false. When there are tap, pan, swipe, or other gesture recognizers present, the event handling behavior is unclear since e.Handled is not explicitly set. Consider explicitly setting e.Handled = true in the else branch to make the intent clear, or document what the default behavior is when the condition is not met.
| } | |
| } | |
| else | |
| { | |
| e.Handled = true; | |
| } |
Co-authored-by: kubaflo <[email protected]>
Review Feedback: PR #32811 - [Android] CollectionView selection with drag/drop gestures on Android - fixRecommendation✅ Approve - Ready to merge Required changes: None Recommended changes:
📋 For full PR Review from agent, expand hereSummaryThis PR correctly fixes issue #32702 where CollectionView item selection doesn't work on Android when DragGestureRecognizer or DropGestureRecognizer is attached to item content. The fix allows event bubbling when only drag/drop recognizers are present, enabling parent controls like CollectionView to handle tap events for selection. Code is well-structured, properly tested, and has no breaking changes. Code ReviewChanged Files:
Core Logic Analysis: The fix adds a new method
When Why This Works:
Code Quality:
Review Comments Addressed:
Test Coverage ReviewHostApp Test Page (
UI Test (
Additional Test Scenarios Created (Sandbox app for comprehensive validation):
All edge cases are covered by the logic. TestingManual Testing Status: Code Analysis Testing: ✅ Completed
Test Code Validation: ✅ Comprehensive UI tests included in PR Recommended Testing Steps (for reviewers with Android device): export DEVICE_UDID=$(adb devices | grep device | awk '{print $1}' | head -1)
dotnet build src/Controls/samples/Controls.Sample.Sandbox/Maui.Controls.Sample.Sandbox.csproj -f net10.0-android -t:RunExpected behavior:
Security Review✅ No security concerns The change is isolated to touch event handling logic and doesn't introduce any new attack vectors or data exposure risks. Breaking Changes✅ No breaking changes
Documentation✅ Adequate The PR includes:
Optional enhancement: Add XML docs to Issues to AddressMust Fix Before MergeNone Should Fix (Recommended)None - code is production-ready as-is Optional Improvements
Approval Checklist
Review Metadata
|
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description of Change
Added logic to allow event bubbling when only DragGestureRecognizer or DropGestureRecognizer are present, enabling CollectionView item selection to work correctly on Android. Includes new test case and UI test to verify the fix for issue #32702.
Issues Fixed
Fixes #32702