Skip to content

[Android] Prevent CollectionView SelectionChanged from triggering on SwipeView gesture#30652

Merged
jfversluis merged 5 commits intodotnet:inflight/currentfrom
Vignesh-SF3580:fix-15778
Dec 1, 2025
Merged

[Android] Prevent CollectionView SelectionChanged from triggering on SwipeView gesture#30652
jfversluis merged 5 commits intodotnet:inflight/currentfrom
Vignesh-SF3580:fix-15778

Conversation

@Vignesh-SF3580
Copy link
Contributor

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

  • Android
  • Windows
  • iOS
  • Mac

Issues Fixed

Fixes #15778

Screenshots

Before Issue Fix After Issue Fix
Before15778.mov
After15778.mov

@dotnet-policy-service
Copy link
Contributor

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.

@dotnet-policy-service dotnet-policy-service bot added community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration labels Jul 16, 2025
@Vignesh-SF3580 Vignesh-SF3580 marked this pull request as ready for review July 16, 2025 13:32
Copilot AI review requested due to automatic review settings July 16, 2025 13:32
@Vignesh-SF3580 Vignesh-SF3580 requested a review from a team as a code owner July 16, 2025 13: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 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);
Copy link

Copilot AI Jul 16, 2025

Choose a reason for hiding this comment

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

The conditional check should include a comment explaining why parent touch propagation is prevented during swipe gestures to improve code maintainability.

Suggested change
ResetSwipe(e);
ResetSwipe(e);
// Prevent parent touch propagation during swipe gestures to avoid interference with swipe functionality.

Copilot uses AI. Check for mistakes.
@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vhugogarcia
Copy link
Contributor

Thank you so much for helping to solve this issue. Looks great

@PureWeen PureWeen modified the milestones: .NET 9 SR10, .NET 9 SR12 Aug 4, 2025
@PureWeen PureWeen modified the milestones: .NET 9 SR12, .NET 10 SR1 Sep 10, 2025
@jsuarezruiz
Copy link
Contributor

/rebase

@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@jsuarezruiz jsuarezruiz left a comment

Choose a reason for hiding this comment

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

LGTM, just triggered a new build waiting for tests results.

@PureWeen PureWeen removed this from the .NET 10 SR1 milestone Nov 4, 2025
@PureWeen PureWeen modified the milestones: .NET 10 SR1, .NET 10.0 SR2 Nov 4, 2025
@vhugogarcia
Copy link
Contributor

thanks @jsuarezruiz and @PureWeen, I hope this change can be merge on next release of .NET MAUI 10 😃

@github-project-automation github-project-automation bot moved this from Todo to Approved in MAUI SDK Ongoing Dec 1, 2025
@jfversluis jfversluis changed the base branch from main to inflight/current December 1, 2025 08:38
@jfversluis jfversluis merged commit 647cfc2 into dotnet:inflight/current Dec 1, 2025
78 checks passed
@github-project-automation github-project-automation bot moved this from Approved to Done in MAUI SDK Ongoing Dec 1, 2025
PureWeen pushed a commit that referenced this pull request Dec 3, 2025
…gesture (#30652)

Added test.

Updated Issue15778.cs

Updated Issue15778.cs

Updated MauiSwipeView.cs
PureWeen pushed a commit that referenced this pull request Dec 3, 2025
…gesture (#30652)

Added test.

Updated Issue15778.cs

Updated Issue15778.cs

Updated MauiSwipeView.cs
github-actions bot pushed a commit that referenced this pull request Dec 5, 2025
…gesture (#30652)

Added test.

Updated Issue15778.cs

Updated Issue15778.cs

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

Labels

community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

CollectionView.SelectionChanged gets fired if a CollectionView.SwipeView is added to ItemTemplate [ANDROID]

6 participants