[Android] Prevent CollectionView SelectionChanged from triggering on SwipeView gesture#30652
Conversation
|
Hey there @@Vignesh-SF3580! 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.
Pull Request Overview
This PR fixes an issue where CollectionView.SelectionChanged event was incorrectly triggered when users performed swipe gestures on SwipeView items within a CollectionView on Android. The root cause was that SwipeView was propagating touch events to its parent CollectionView even after swipe gestures occurred.
- Added conditional check in MauiSwipeView to prevent parent touch propagation during swipe gestures
- Added comprehensive UI test to verify swipe gestures don't trigger CollectionView selection
- Created test UI page demonstrating the issue with SwipeView inside CollectionView
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Core/src/Platform/Android/MauiSwipeView.cs | Added conditional check to prevent PropagateParentTouch() when swiping |
| src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue15778.cs | NUnit test to verify swipe doesn't trigger selection |
| src/Controls/tests/TestCases.HostApp/Issues/Issue15778.cs | Test UI page with SwipeView in CollectionView setup |
Comments suppressed due to low confidence (1)
src/Controls/tests/TestCases.HostApp/Issues/Issue15778.cs:38
- The label inside the SwipeView should have an AutomationId to ensure proper test automation. The test relies on 'Item 1' text but the label lacks an AutomationId for reliable element identification.
var label = new Label { Padding = new Thickness(10) };
| ProcessTouchSwipeItems(touchUpPoint); | ||
| else | ||
| { | ||
| ResetSwipe(e); |
There was a problem hiding this comment.
The conditional check should include a comment explaining why parent touch propagation is prevented during swipe gestures to improve code maintainability.
| ResetSwipe(e); | |
| ResetSwipe(e); | |
| // Prevent parent touch propagation during swipe gestures to avoid interference with swipe functionality. |
|
/azp run MAUI-UITests-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Thank you so much for helping to solve this issue. Looks great |
|
/rebase |
a10e9cf to
c232098
Compare
|
/azp run MAUI-UITests-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
jsuarezruiz
left a comment
There was a problem hiding this comment.
LGTM, just triggered a new build waiting for tests results.
|
thanks @jsuarezruiz and @PureWeen, I hope this change can be merge on next release of .NET MAUI 10 😃 |
…gesture (#30652) Added test. Updated Issue15778.cs Updated Issue15778.cs Updated MauiSwipeView.cs
…gesture (#30652) Added test. Updated Issue15778.cs Updated Issue15778.cs Updated MauiSwipeView.cs
…gesture (#30652) Added test. Updated Issue15778.cs Updated Issue15778.cs Updated MauiSwipeView.cs
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!
Issue Detail
CollectionView.SelectionChanged gets fired when performing swipe using swipe view.
Root Cause
SwipeView implementation calls PropagateParentTouch() after every touch release. This causes the parent CollectionView to receive click events and trigger SelectionChanged inappropriately when users perform swipe actions.
Description of Change
Added a conditional check to prevent parent touch propagation when a swipe gesture has occurred.
Tested the behavior in the following platforms
Issues Fixed
Fixes #15778
Screenshots
Before15778.mov
After15778.mov