Skip to content

[Android] Fix CollectionView item selection not triggered when using PointerGestureRecognizer - #37952

Merged
kubaflo merged 3 commits into
dotnet:inflight/currentfrom
devanathan-vaithiyanathan:34491-fix
Oct 14, 2026
Merged

kubaflo merged 3 commits into
dotnet:inflight/currentfrom
devanathan-vaithiyanathan:34491-fix

Conversation

@devanathan-vaithiyanathan

@devanathan-vaithiyanathan devanathan-vaithiyanathan commented Aug 28, 2026 •

Copy link
Copy Markdown
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!

Root cause

In PR #34209 , the pointer gesture handling returned true whenever a PointerGestureRecognizer was present (return baseHandled || pointerHandled). This was required to ensure Android continued delivering PointerMoved and PointerReleased events. However, when the gesture was used inside a CollectionView.ItemTemplate, the same handling consumed the touch event before it could reach the CollectionView item. As a result, the CollectionView did not receive its native click event, preventing item selection and SelectionChanged from being triggered.

Issue Details

On Android, adding a PointerGestureRecognizer to a view inside a CollectionView ItemTemplate prevented item selection. Tapping the item raised pointer events, but SelectionChanged did not fire.

Description of Change

Updated Android pointer gesture handling in:

  • PointerGestureHandler now examines the native Android view hierarchy to determine whether the pointer-enabled view is inside a clickable native view.
  • TapAndPanGestureDetector retains the touch sequence only when no clickable native view owns it.

Issues Fixed

Fixes #34491

Regarding test case

The test case requires user interaction, so haven't added a test case.

Tested the behavior in the following platforms.

  • Android
  • Windows
  • iOS
  • Mac
Before After
Android
Before.mov
Android
After.mov

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 37952

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 37952"

@dotnet-policy-service dotnet-policy-service Bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Aug 28, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Aug 30, 2026

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Expert Review — 5 findings

See inline comments for details.

MauiBot

This comment was marked as outdated.

@MauiBot MauiBot added s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-fix-win AI found a better alternative fix than the PR s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) and removed s/agent-review-in-progress AI review is currently running for this PR labels Aug 30, 2026

@kubaflo kubaflo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's the status of this one? Is it ready for review?

@devanathan-vaithiyanathan devanathan-vaithiyanathan changed the title [WIP][Android] Fix CollectionView item selection not triggered when using PointerGestureRecognizer [Android] Fix CollectionView item selection not triggered when using PointerGestureRecognizer Sep 1, 2026
@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Sep 2, 2026

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Expert Review — 1 findings

See inline comments for details.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Oct 7, 2026
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Note

🔍 /review started

AzDO build 15599373 is running for android.

The s/agent-review-in-progress label stays on this PR while the run is active. The final recommendation and outcome labels are posted only after Gate, expert review, and Deep UI tests finish.

@kubaflo

This comment has been minimized.

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Note

🔍 /review skipped — a review is already running

This PR already holds the s/agent-review-in-progress lock, so a new review was not started (only one review runs at a time to avoid duplicate, racing reviews). The in-flight run must finish first — this can take a while when the deep UI-test stage is queued.

Re-comment /review once it completes to start a fresh run.

🔍 Automated message from the .NET MAUI Copilot reviewer pipeline.

@MauiBot

This comment has been minimized.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Oct 7, 2026
@PureWeen

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Oct 7, 2026
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Note

🔍 /review started

AzDO build 15602033 is running for android.

The s/agent-review-in-progress label stays on this PR while the run is active. The final recommendation and outcome labels are posted only after Gate, expert review, and Deep UI tests finish.

@MauiBot

MauiBot commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

AI Review Summary

@devanathan-vaithiyanathan — new AI review results are available based on commit f7b2c45.

Gate No Tests Confidence Unknown Platform Android

Review status: Evidence-first output is incomplete. Missing or skipped required artifacts cannot support approval; existing Gate and blocking findings remain authoritative.


🗂️ Review Sessions — click to expand
🚦 Gate — Test Before & After Fix

Gate Result: ⚠️ SKIPPED

No tests were detected in this PR.

Recommendation: Add tests to verify the fix using the write-tests-agent.


📋 Pre-Flight — Context & Validation

⚠️ Pre-Flight did not produce output on this run.

The Copilot expert-review task ended before this phase was persisted, usually because the review-stage time budget expired or the CI agent encountered a transient authentication/runtime problem. Earlier completed sections remain valid, but this review is incomplete without this phase.

Next step: re-comment /review to retry on a fresh agent. If this repeats across runs, a maintainer should inspect the reviewer token and Task 3 logs.


🔬 Code Review — Deep Analysis

⚠️ Code Review did not produce output on this run.

The Copilot expert-review task ended before this phase was persisted, usually because the review-stage time budget expired or the CI agent encountered a transient authentication/runtime problem. Earlier completed sections remain valid, but this review is incomplete without this phase.

Next step: re-comment /review to retry on a fresh agent. If this repeats across runs, a maintainer should inspect the reviewer token and Task 3 logs.


🛠️ Try-Fix — Analysis & Comparison

⚠️ Try-Fix did not produce output on this run.

The Copilot expert-review task ended before this phase was persisted, usually because the review-stage time budget expired or the CI agent encountered a transient authentication/runtime problem. Earlier completed sections remain valid, but this review is incomplete without this phase.

Next step: re-comment /review to retry on a fresh agent. If this repeats across runs, a maintainer should inspect the reviewer token and Task 3 logs.


🏁 Report — Final Recommendation

⚠️ Report / Final Recommendation did not produce output on this run.

The Copilot expert-review task ended before this phase was persisted, usually because the review-stage time budget expired or the CI agent encountered a transient authentication/runtime problem. Earlier completed sections remain valid, but this review is incomplete without this phase.

Next step: re-comment /review to retry on a fresh agent. If this repeats across runs, a maintainer should inspect the reviewer token and Task 3 logs.


📱 UI Tests — Button,Label,Layout

Detected UI test categories: Button,Label,Layout

[!WARNING]
No UI test results were produced for the detected categories. The trusted gate was
skipped before build/test verification, so it does not prove that the PR build is healthy.
The deep UI stage also returned no results; inspect the independent CI checks and retry the
review if those categories still need coverage.


🧭 Next Steps — review latest findings

No alternative fix was selected for this run. Review the session findings and CI results before merging.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Oct 14, 2026
@MauiBot

MauiBot commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@devanathan-vaithiyanathan — existing-test verification for commit f7b2c452.

Result SKIPPED Platform Android Commit f7b2c452


🧪 Gate analysis — click to expand

⚠ Skipped. No runnable PR tests were selected. The fix has not been verified by this gate.

No interpretable test-group summary was produced. No additional test execution is inferred.

PR head: f7b2c452.

Without-fix baseline: e5d105e9.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Oct 14, 2026
@kubaflo
kubaflo changed the base branch from main to inflight/current October 14, 2026 15:55
@kubaflo
kubaflo merged commit cc8e349 into dotnet:inflight/current Oct 14, 2026
215 of 236 checks passed
@github-actions github-actions Bot added this to the .NET 10 SR12 milestone Oct 14, 2026
kubaflo added a commit that referenced this pull request Oct 14, 2026
…ter gestures (#37952) (#39387)

<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Description of Change

<!-- Enter description of the fix in this section -->

Exact backport of [#37952](#37952),
merged into `inflight/current` as
[`cc8e3495d1e67c9e84964d80671424c4fa9fa39b`](cc8e349).

**Target exception:** `inflight/candidate` is explicitly requested for
this servicing backport, rather than the template's usual `main` target.

Preserves the final merged fix without additional dependencies, tests,
or redesign: inspect the Android native view hierarchy for a clickable
view, and retain pointer touch ownership only for the initial Down event
when no clickable native view owns the sequence. This prevents a
PointerGestureRecognizer inside a CollectionView item template from
swallowing native item selection.

Only `PointerGestureHandler.cs` and `TapAndPanGestureDetector.cs`
change: 19 insertions and one deletion. Candidate
`e741040bbd9ed84f5ee9fadab207501e4fa0e0a2` has byte-identical pre-fix
contents to the source commit's parent in both files. The backport has
byte-identical post-fix contents to the merged source. Both deltas have
stable patch-id `845193da6780e357ad479b85bedc5560f875f860`. Open and
merged Candidate PRs were rechecked by source number, issue number, and
mechanism immediately before publishing; no duplicate was found.

**Local validation**

Host SDK: `11.0.100-preview.6.26359.118`; the Android build targets
`net10.0-android36.0`, and managed tests run on `net10.0`.

| Command | Result |
| --- | --- |
| `dotnet build Microsoft.Maui.BuildTasks.slnf --no-restore
-p:BuildTaskOnlyBuild=true -p:MauiPlatforms=net10.0-android36.0
-p:IncludePreviousTfms=false -v:minimal` | Initial attempt failed with
missing dependency assets (`NETSDK1004`) and .NET Framework 4.7.2
reference assemblies (`MSB3644`); resolved by the following restore and
retry. |
| `dotnet restore Microsoft.Maui.BuildTasks.slnf
-p:BuildTaskOnlyBuild=true -p:MauiPlatforms=net10.0-android36.0
-p:IncludePreviousTfms=false -v:minimal` | Passed. |
| `dotnet build Microsoft.Maui.BuildTasks.slnf --no-restore
-p:BuildTaskOnlyBuild=true -p:MauiPlatforms=net10.0-android36.0
-p:IncludePreviousTfms=false -v:quiet '-clp:ErrorsOnly;Summary'` |
Passed: 3 warnings, 0 errors. |
| `dotnet build src/Controls/src/Core/Controls.Core.csproj -f
net10.0-android36.0 --no-restore -p:MauiPlatforms=net10.0-android36.0
-p:IncludePreviousTfms=false -v:quiet '-clp:ErrorsOnly;Summary'` |
Passed: 0 warnings, 0 errors. |
| `dotnet test
src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj -f
net10.0 --filter
'FullyQualifiedName~Microsoft.Maui.Controls.Core.UnitTests.PointerGestureRecognizerTests'
-p:MauiPlatforms=net10.0-android36.0 -p:IncludePreviousTfms=false
-v:quiet '-clp:ErrorsOnly;Summary'` | Passed: 25 tests, 0 failed, 0
skipped. |
| `dotnet format whitespace --folder --include
src/Controls/src/Core/Platform/Android/PointerGestureHandler.cs
src/Controls/src/Core/Platform/Android/TapAndPanGestureDetector.cs
--verify-no-changes --verbosity minimal` | Passed; source formatting
preserved. |
| `git diff --check origin/inflight/candidate...HEAD` | Passed. |
| `git diff --exit-code cc8e349 HEAD --
src/Controls/src/Core/Platform/Android/PointerGestureHandler.cs
src/Controls/src/Core/Platform/Android/TapAndPanGestureDetector.cs` |
Passed; exact merged-source postimages. |
| `git diff cc8e349^
cc8e349 \| git patch-id --stable` and
`git diff origin/inflight/candidate...HEAD \| git patch-id --stable` |
Passed; identical patch-id above. |

**Native validation gap:** No emulator/device or manual UI validation
was performed. The focused tests cover managed recognizer behavior, not
Android native touch dispatch, CollectionView selection, or
SelectionChanged. No XCTest, MacCatalyst testing, or foreground/device
UI automation was run. CI results have not been evaluated in this task.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #34491 via backport of
[#37952](#37952).

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: dac2dd94-1d58-4022-b496-1ffe726b7768
kubaflo pushed a commit that referenced this pull request Oct 18, 2026
…PointerGestureRecognizer (#37952)

<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

### Root cause
In PR #34209 , the pointer gesture handling returned true whenever a
PointerGestureRecognizer was present (return baseHandled ||
pointerHandled). This was required to ensure Android continued
delivering PointerMoved and PointerReleased events. However, when the
gesture was used inside a CollectionView.ItemTemplate, the same handling
consumed the touch event before it could reach the CollectionView item.
As a result, the CollectionView did not receive its native click event,
preventing item selection and SelectionChanged from being triggered.
### Issue Details
On Android, adding a PointerGestureRecognizer to a view inside a
CollectionView ItemTemplate prevented item selection. Tapping the item
raised pointer events, but SelectionChanged did not fire.

### Description of Change

<!-- Enter description of the fix in this section -->
Updated Android pointer gesture handling in:  
* PointerGestureHandler now examines the native Android view hierarchy
to determine whether the pointer-enabled view is inside a clickable
native view.
* TapAndPanGestureDetector retains the touch sequence only when no
clickable native view owns it.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #34491 

### Regarding test case
The test case requires user interaction, so haven't added a test case.

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

**Tested the behavior in the following platforms.**
- [x] Android
- [ ] Windows
- [ ] iOS
- [ ] Mac


| Before  | After  |
|---------|--------|
| **Android**<br> <video
src="https://github.com/user-attachments/assets/3b880f2b-f76a-4fe8-ac50-03c65e2a10e0"
width="300" height="600"> | **Android**<br> <video
src="https://github.com/user-attachments/assets/e21172b8-d0fa-48e0-93a9-5c732c7159a9"
width="300" height="600"> |
kubaflo added a commit that referenced this pull request Oct 18, 2026
…ter gestures (#37952) (#39387)

<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Description of Change

<!-- Enter description of the fix in this section -->

Exact backport of [#37952](#37952),
merged into `inflight/current` as
[`cc8e3495d1e67c9e84964d80671424c4fa9fa39b`](cc8e349).

**Target exception:** `inflight/candidate` is explicitly requested for
this servicing backport, rather than the template's usual `main` target.

Preserves the final merged fix without additional dependencies, tests,
or redesign: inspect the Android native view hierarchy for a clickable
view, and retain pointer touch ownership only for the initial Down event
when no clickable native view owns the sequence. This prevents a
PointerGestureRecognizer inside a CollectionView item template from
swallowing native item selection.

Only `PointerGestureHandler.cs` and `TapAndPanGestureDetector.cs`
change: 19 insertions and one deletion. Candidate
`e741040bbd9ed84f5ee9fadab207501e4fa0e0a2` has byte-identical pre-fix
contents to the source commit's parent in both files. The backport has
byte-identical post-fix contents to the merged source. Both deltas have
stable patch-id `845193da6780e357ad479b85bedc5560f875f860`. Open and
merged Candidate PRs were rechecked by source number, issue number, and
mechanism immediately before publishing; no duplicate was found.

**Local validation**

Host SDK: `11.0.100-preview.6.26359.118`; the Android build targets
`net10.0-android36.0`, and managed tests run on `net10.0`.

| Command | Result |
| --- | --- |
| `dotnet build Microsoft.Maui.BuildTasks.slnf --no-restore
-p:BuildTaskOnlyBuild=true -p:MauiPlatforms=net10.0-android36.0
-p:IncludePreviousTfms=false -v:minimal` | Initial attempt failed with
missing dependency assets (`NETSDK1004`) and .NET Framework 4.7.2
reference assemblies (`MSB3644`); resolved by the following restore and
retry. |
| `dotnet restore Microsoft.Maui.BuildTasks.slnf
-p:BuildTaskOnlyBuild=true -p:MauiPlatforms=net10.0-android36.0
-p:IncludePreviousTfms=false -v:minimal` | Passed. |
| `dotnet build Microsoft.Maui.BuildTasks.slnf --no-restore
-p:BuildTaskOnlyBuild=true -p:MauiPlatforms=net10.0-android36.0
-p:IncludePreviousTfms=false -v:quiet '-clp:ErrorsOnly;Summary'` |
Passed: 3 warnings, 0 errors. |
| `dotnet build src/Controls/src/Core/Controls.Core.csproj -f
net10.0-android36.0 --no-restore -p:MauiPlatforms=net10.0-android36.0
-p:IncludePreviousTfms=false -v:quiet '-clp:ErrorsOnly;Summary'` |
Passed: 0 warnings, 0 errors. |
| `dotnet test
src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj -f
net10.0 --filter
'FullyQualifiedName~Microsoft.Maui.Controls.Core.UnitTests.PointerGestureRecognizerTests'
-p:MauiPlatforms=net10.0-android36.0 -p:IncludePreviousTfms=false
-v:quiet '-clp:ErrorsOnly;Summary'` | Passed: 25 tests, 0 failed, 0
skipped. |
| `dotnet format whitespace --folder --include
src/Controls/src/Core/Platform/Android/PointerGestureHandler.cs
src/Controls/src/Core/Platform/Android/TapAndPanGestureDetector.cs
--verify-no-changes --verbosity minimal` | Passed; source formatting
preserved. |
| `git diff --check origin/inflight/candidate...HEAD` | Passed. |
| `git diff --exit-code cc8e349 HEAD --
src/Controls/src/Core/Platform/Android/PointerGestureHandler.cs
src/Controls/src/Core/Platform/Android/TapAndPanGestureDetector.cs` |
Passed; exact merged-source postimages. |
| `git diff cc8e349^
cc8e349 \| git patch-id --stable` and
`git diff origin/inflight/candidate...HEAD \| git patch-id --stable` |
Passed; identical patch-id above. |

**Native validation gap:** No emulator/device or manual UI validation
was performed. The focused tests cover managed recognizer behavior, not
Android native touch dispatch, CollectionView selection, or
SelectionChanged. No XCTest, MacCatalyst testing, or foreground/device
UI automation was run. CI results have not been evaluated in this task.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #34491 via backport of
[#37952](#37952).

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: dac2dd94-1d58-4022-b496-1ffe726b7768
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 14, 2026

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — f7b2c452 Deployed Sep 9, 2026 by devanathan-vaithiyanathan via conclusion #1813
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-controls-collectionview CollectionView, CarouselView, IndicatorView community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/android s/agent-review-incomplete AI review did not complete all expected phases s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Android] CollectionView item selection not triggered when using PointerGestureRecognizer

6 participants