Skip to content

[Android] Fix TapGestureRecognizer not firing when a View.Touch handler sets Handled to false - #40307

Merged
kubaflo merged 3 commits into
dotnet:candidate/11.0.1xx-sr2from
marcelomoresco:fix/32226-android-tap-native-touch-handler
Nov 17, 2026
Merged

kubaflo merged 3 commits into
dotnet:candidate/11.0.1xx-sr2from
marcelomoresco:fix/32226-android-tap-native-touch-handler

Conversation

@marcelomoresco

@marcelomoresco marcelomoresco commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Target Branch

This PR is for Initial base
New features, API changes, or .NET 12 work (including .NET 12 fixes) main
.NET 11 servicing fixes net11, for review
Older servicing, release integration, infrastructure, or documentation The branch designated for that work

For .NET 11 fixes, only a maintainer retargets the approved PR to the active
inflight lane and merges it after CI validates that final base. Do not merge
individual fixes directly into net11; agents must not retarget or merge.

Description of Change

On Android, the gesture manager subscribes to View.Touch and keeps the touch sequence by setting e.Handled = true on ACTION_DOWN. .NET for Android raises every Touch subscriber with one shared TouchEventArgs, so a handler added after ours (the workaround from #23901 (comment)) overwrites it with false. Android then falls back to View.onTouchEvent, which only keeps the sequence for clickable views, so ACTION_UP never reaches the gesture detector and the tap is lost. #29649 hid this by making these views Clickable; #31486 removed that because it broke TalkBack (#31483).

This sets ContextClickable = true on enabled views whose touch sequence our listener consumes (tap, including Span taps, pan, swipe, pinch, drag; not pointer-only or long-press-only views) and restores the original value when the gesture is removed, the view is disabled, or the manager is torn down. View.onTouchEvent treats CONTEXT_CLICKABLE like CLICKABLE, but isClickable() and the ACTION_CLICK path TalkBack uses don't change, so #31486's behavior stays. Disabled views are skipped so they keep passing touches to the parent's gestures (same reason as #29814).

Tests

Issue32226 (Gestures, Android):

  • TapGestureFiresWhenNativeTouchHandlerDoesNotHandleTouch fails without the fix ("Not tapped") and passes with it.
  • DoubleTapGestureFiresWhenNativeTouchHandlerDoesNotHandleTouch fails without the fix ("Not double tapped") and passes with it.
  • TapOnViewDisabledAtRuntimeReachesParent (child disabled at runtime, tap reaches the parent) fails if UpdateIsEnabled doesn't restore ContextClickable.
  • TapGestureFiresWithoutNativeTouchHandler passes with and without it.

No new failures in the Gestures category. With TalkBack on, the tap target still reports clickable=false, and focus + double-tap fires Tapped.

Issues Fixed

Fixes #32226

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@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 -- 40307

Or

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

@dotnet-policy-service dotnet-policy-service Bot added the community ✨ Community Contribution label Nov 16, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Hey there @marcelomoresco! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@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 Nov 16, 2026
@kubaflo

kubaflo commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

/rebase

…er sets Handled to false

A View.Touch subscriber added after the gesture manager's (for example the
workaround from dotnet#23901) overwrites e.Handled with false. Android then falls back
to View.onTouchEvent, which only keeps the touch sequence on clickable views, so
the view never got ACTION_UP and the tap was lost. dotnet#29649 hid this by making the
view Clickable; dotnet#31486 removed that because it broke TalkBack activation (dotnet#31483).

Mark enabled views that have an accessible tap gesture as ContextClickable
instead. View.onTouchEvent treats it like Clickable, but isClickable() and the
ACTION_CLICK path TalkBack relies on are unchanged. Disabled views are left alone
so they keep passing touches to their parent's gestures.

Fixes dotnet#32226
@github-actions
github-actions Bot force-pushed the fix/32226-android-tap-native-touch-handler branch from c135405 to d1dab8f Compare November 16, 2026 21:38
@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@MauiBot

MauiBot commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@marcelomoresco — existing-test verification; Setup did not capture a tested commit.

Result INCONCLUSIVE Platform Android


🧪 Gate analysis — click to expand

⚠ Inconclusive. Setup, build, or execution did not produce a conclusive result. This does not prove the fix is incorrect.

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

Setup did not capture a verified PR head; no commit is claimed as tested.

No immutable without-fix baseline was prepared.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Nov 16, 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 Nov 16, 2026
@MauiBot

MauiBot commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@marcelomoresco — existing-test verification; Setup did not capture a tested commit.

Result INCONCLUSIVE Platform Android


🧪 Gate analysis — click to expand

⚠ Inconclusive. Setup, build, or execution did not produce a conclusive result. This does not prove the fix is incorrect.

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

Setup did not capture a verified PR head; no commit is claimed as tested.

No immutable without-fix baseline was prepared.

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

@github-actions github-actions Bot 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.

Expert Review — 2 findings

Reviewed commit d1dab8f.

See inline comments for details.

…nd disabling

ContextClickable now follows the recognizers whose ACTION_DOWN our Touch
listener consumes (tap including Span taps, pan, swipe, drag, pinch) instead of
HasAccessibleTapGesture(), so double taps and other gestures keep their touch
sequence too. Pointer-only and long-press-only views stay unchanged.

Add a double-tap case with a native Touch handler, and make the parent
pass-through case disable an enabled child at runtime so it covers restoring
ContextClickable from UpdateIsEnabled().
@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 Nov 16, 2026
@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Nov 17, 2026

@github-actions github-actions Bot 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.

Expert Review — 0 findings

Reviewed commit dcdf559.

@kubaflo

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Tests Failure Analysis

@marcelomoresco — test-failure analysis for commit dcdf559.

Scope CI failures Commit dcdf559


🧪 CI Analysis — click to expand
📊 maui-pr

No failures found.


🧪 maui-pr-devicetests

**Insufficient (redacted) both linked iOS work items are flagged incomplete; exit 1 alone does not establish a crash. Verify terminal results.


🧪 maui-pr-uitests

Matched failures below repeat the same platform/test/diagnostic on linked net11 runs, outside the changed Android implementation and isolated new page.

**Insufficient (redacted) other failed setup/legs, including Android Gradle initialization, lack root diagnostics; Android gesture-test coverage is unverified.


🧭 Follow-up — actions and refresh

Next action: restore missing logs/results; compare unresolved tests at identical setup without this patch, and verify Android gesture outcomes.

Maintainers: comment /review tests to refresh this report.

@marcelomoresco

Copy link
Copy Markdown
Contributor Author

The 🟡 items are all iOS, Mac or Windows tests (Border clipping, hover resources, NavigationPage/CollectionView leaks, refresh/Entry/search-icon snapshots, orientation scroll), and this PR only changes GesturePlatformManager.Android.cs. 14 of the 19 failed UI tests fail the same way on #40316 and #40318, which share no code with this one. The Android UI test legs died at checkout before running, so could you re-run them to get the gesture coverage?

@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 Nov 17, 2026
@MauiBot

MauiBot commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@marcelomoresco — existing-test verification; Setup did not capture a tested commit.

Result INCONCLUSIVE Platform Android


🧪 Gate analysis — click to expand

⚠ Inconclusive. Setup, build, or execution did not produce a conclusive result. This does not prove the fix is incorrect.

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

Setup did not capture a verified PR head; no commit is claimed as tested.

No immutable without-fix baseline was prepared.

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

@github-actions github-actions Bot 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.

Expert Review — 0 findings

Reviewed commit dcdf559.

@kubaflo
kubaflo changed the base branch from net11 to candidate/11.0.1xx-sr2 November 17, 2026 11:22
@kubaflo
kubaflo merged commit 9843069 into dotnet:candidate/11.0.1xx-sr2 Nov 17, 2026
139 of 182 checks passed
kubaflo added a commit that referenced this pull request Nov 17, 2026
…er sets Handled to false (#40307)

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

On Android, the gesture manager subscribes to `View.Touch` and keeps the
touch sequence by setting `e.Handled = true` on `ACTION_DOWN`. .NET for
Android raises every `Touch` subscriber with one shared
`TouchEventArgs`, so a handler added after ours (the workaround from
#23901 (comment))
overwrites it with `false`. Android then falls back to
`View.onTouchEvent`, which only keeps the sequence for clickable views,
so `ACTION_UP` never reaches the gesture detector and the tap is lost.
#29649 hid this by making these views `Clickable`; #31486 removed that
because it broke TalkBack (#31483).

This sets `ContextClickable = true` on enabled views whose touch
sequence our listener consumes (tap, including Span taps, pan, swipe,
pinch, drag; not pointer-only or long-press-only views) and restores the
original value when the gesture is removed, the view is disabled, or the
manager is torn down. `View.onTouchEvent` treats `CONTEXT_CLICKABLE`
like `CLICKABLE`, but `isClickable()` and the `ACTION_CLICK` path
TalkBack uses don't change, so #31486's behavior stays. Disabled views
are skipped so they keep passing touches to the parent's gestures (same
reason as #29814).

#### Tests

`Issue32226` (Gestures, Android):
- `TapGestureFiresWhenNativeTouchHandlerDoesNotHandleTouch` fails
without the fix ("Not tapped") and passes with it.
- `DoubleTapGestureFiresWhenNativeTouchHandlerDoesNotHandleTouch` fails
without the fix ("Not double tapped") and passes with it.
- `TapOnViewDisabledAtRuntimeReachesParent` (child disabled at runtime,
tap reaches the parent) fails if `UpdateIsEnabled` doesn't restore
`ContextClickable`.
- `TapGestureFiresWithoutNativeTouchHandler` passes with and without it.

No new failures in the `Gestures` category. With TalkBack on, the tap
target still reports `clickable=false`, and focus + double-tap fires
`Tapped`.

### Issues Fixed

Fixes #32226

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
…er sets Handled to false (#40307)

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

On Android, the gesture manager subscribes to `View.Touch` and keeps the
touch sequence by setting `e.Handled = true` on `ACTION_DOWN`. .NET for
Android raises every `Touch` subscriber with one shared
`TouchEventArgs`, so a handler added after ours (the workaround from
#23901 (comment))
overwrites it with `false`. Android then falls back to
`View.onTouchEvent`, which only keeps the sequence for clickable views,
so `ACTION_UP` never reaches the gesture detector and the tap is lost.
#29649 hid this by making these views `Clickable`; #31486 removed that
because it broke TalkBack (#31483).

This sets `ContextClickable = true` on enabled views whose touch
sequence our listener consumes (tap, including Span taps, pan, swipe,
pinch, drag; not pointer-only or long-press-only views) and restores the
original value when the gesture is removed, the view is disabled, or the
manager is torn down. `View.onTouchEvent` treats `CONTEXT_CLICKABLE`
like `CLICKABLE`, but `isClickable()` and the `ACTION_CLICK` path
TalkBack uses don't change, so #31486's behavior stays. Disabled views
are skipped so they keep passing touches to the parent's gestures (same
reason as #29814).

#### Tests

`Issue32226` (Gestures, Android):
- `TapGestureFiresWhenNativeTouchHandlerDoesNotHandleTouch` fails
without the fix ("Not tapped") and passes with it.
- `DoubleTapGestureFiresWhenNativeTouchHandlerDoesNotHandleTouch` fails
without the fix ("Not double tapped") and passes with it.
- `TapOnViewDisabledAtRuntimeReachesParent` (child disabled at runtime,
tap reaches the parent) fails if `UpdateIsEnabled` doesn't restore
`ContextClickable`.
- `TapGestureFiresWithoutNativeTouchHandler` passes with and without it.

No new failures in the `Gestures` category. With TalkBack on, the tap
target still reports `clickable=false`, and focus + double-tap fires
`Tapped`.

### Issues Fixed

Fixes #32226

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
…er sets Handled to false (#40307)

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

On Android, the gesture manager subscribes to `View.Touch` and keeps the
touch sequence by setting `e.Handled = true` on `ACTION_DOWN`. .NET for
Android raises every `Touch` subscriber with one shared
`TouchEventArgs`, so a handler added after ours (the workaround from
#23901 (comment))
overwrites it with `false`. Android then falls back to
`View.onTouchEvent`, which only keeps the sequence for clickable views,
so `ACTION_UP` never reaches the gesture detector and the tap is lost.
#29649 hid this by making these views `Clickable`; #31486 removed that
because it broke TalkBack (#31483).

This sets `ContextClickable = true` on enabled views whose touch
sequence our listener consumes (tap, including Span taps, pan, swipe,
pinch, drag; not pointer-only or long-press-only views) and restores the
original value when the gesture is removed, the view is disabled, or the
manager is torn down. `View.onTouchEvent` treats `CONTEXT_CLICKABLE`
like `CLICKABLE`, but `isClickable()` and the `ACTION_CLICK` path
TalkBack uses don't change, so #31486's behavior stays. Disabled views
are skipped so they keep passing touches to the parent's gestures (same
reason as #29814).

#### Tests

`Issue32226` (Gestures, Android):
- `TapGestureFiresWhenNativeTouchHandlerDoesNotHandleTouch` fails
without the fix ("Not tapped") and passes with it.
- `DoubleTapGestureFiresWhenNativeTouchHandlerDoesNotHandleTouch` fails
without the fix ("Not double tapped") and passes with it.
- `TapOnViewDisabledAtRuntimeReachesParent` (child disabled at runtime,
tap reaches the parent) fails if `UpdateIsEnabled` doesn't restore
`ContextClickable`.
- `TapGestureFiresWithoutNativeTouchHandler` passes with and without it.

No new failures in the `Gestures` category. With TalkBack on, the tap
target still reports `clickable=false`, and focus + double-tap fires
`Tapped`.

### Issues Fixed

Fixes #32226

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
…er sets Handled to false (#40307)

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

On Android, the gesture manager subscribes to `View.Touch` and keeps the
touch sequence by setting `e.Handled = true` on `ACTION_DOWN`. .NET for
Android raises every `Touch` subscriber with one shared
`TouchEventArgs`, so a handler added after ours (the workaround from
#23901 (comment))
overwrites it with `false`. Android then falls back to
`View.onTouchEvent`, which only keeps the sequence for clickable views,
so `ACTION_UP` never reaches the gesture detector and the tap is lost.
#29649 hid this by making these views `Clickable`; #31486 removed that
because it broke TalkBack (#31483).

This sets `ContextClickable = true` on enabled views whose touch
sequence our listener consumes (tap, including Span taps, pan, swipe,
pinch, drag; not pointer-only or long-press-only views) and restores the
original value when the gesture is removed, the view is disabled, or the
manager is torn down. `View.onTouchEvent` treats `CONTEXT_CLICKABLE`
like `CLICKABLE`, but `isClickable()` and the `ACTION_CLICK` path
TalkBack uses don't change, so #31486's behavior stays. Disabled views
are skipped so they keep passing touches to the parent's gestures (same
reason as #29814).

#### Tests

`Issue32226` (Gestures, Android):
- `TapGestureFiresWhenNativeTouchHandlerDoesNotHandleTouch` fails
without the fix ("Not tapped") and passes with it.
- `DoubleTapGestureFiresWhenNativeTouchHandlerDoesNotHandleTouch` fails
without the fix ("Not double tapped") and passes with it.
- `TapOnViewDisabledAtRuntimeReachesParent` (child disabled at runtime,
tap reaches the parent) fails if `UpdateIsEnabled` doesn't restore
`ContextClickable`.
- `TapGestureFiresWithoutNativeTouchHandler` passes with and without it.

No new failures in the `Gestures` category. With TalkBack on, the tap
target still reports `clickable=false`, and focus + double-tap fires
`Tapped`.

### Issues Fixed

Fixes #32226

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 19, 2026
…er sets Handled to false (#40307)

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

On Android, the gesture manager subscribes to `View.Touch` and keeps the
touch sequence by setting `e.Handled = true` on `ACTION_DOWN`. .NET for
Android raises every `Touch` subscriber with one shared
`TouchEventArgs`, so a handler added after ours (the workaround from
#23901 (comment))
overwrites it with `false`. Android then falls back to
`View.onTouchEvent`, which only keeps the sequence for clickable views,
so `ACTION_UP` never reaches the gesture detector and the tap is lost.
#29649 hid this by making these views `Clickable`; #31486 removed that
because it broke TalkBack (#31483).

This sets `ContextClickable = true` on enabled views whose touch
sequence our listener consumes (tap, including Span taps, pan, swipe,
pinch, drag; not pointer-only or long-press-only views) and restores the
original value when the gesture is removed, the view is disabled, or the
manager is torn down. `View.onTouchEvent` treats `CONTEXT_CLICKABLE`
like `CLICKABLE`, but `isClickable()` and the `ACTION_CLICK` path
TalkBack uses don't change, so #31486's behavior stays. Disabled views
are skipped so they keep passing touches to the parent's gestures (same
reason as #29814).

#### Tests

`Issue32226` (Gestures, Android):
- `TapGestureFiresWhenNativeTouchHandlerDoesNotHandleTouch` fails
without the fix ("Not tapped") and passes with it.
- `DoubleTapGestureFiresWhenNativeTouchHandlerDoesNotHandleTouch` fails
without the fix ("Not double tapped") and passes with it.
- `TapOnViewDisabledAtRuntimeReachesParent` (child disabled at runtime,
tap reaches the parent) fails if `UpdateIsEnabled` doesn't restore
`ContextClickable`.
- `TapGestureFiresWithoutNativeTouchHandler` passes with and without it.

No new failures in the `Gestures` category. With TalkBack on, the tap
target still reports `clickable=false`, and focus + double-tap fires
`Tapped`.

### Issues Fixed

Fixes #32226

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 22, 2026
…er sets Handled to false (#40307)

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

On Android, the gesture manager subscribes to `View.Touch` and keeps the
touch sequence by setting `e.Handled = true` on `ACTION_DOWN`. .NET for
Android raises every `Touch` subscriber with one shared
`TouchEventArgs`, so a handler added after ours (the workaround from
#23901 (comment))
overwrites it with `false`. Android then falls back to
`View.onTouchEvent`, which only keeps the sequence for clickable views,
so `ACTION_UP` never reaches the gesture detector and the tap is lost.
#29649 hid this by making these views `Clickable`; #31486 removed that
because it broke TalkBack (#31483).

This sets `ContextClickable = true` on enabled views whose touch
sequence our listener consumes (tap, including Span taps, pan, swipe,
pinch, drag; not pointer-only or long-press-only views) and restores the
original value when the gesture is removed, the view is disabled, or the
manager is torn down. `View.onTouchEvent` treats `CONTEXT_CLICKABLE`
like `CLICKABLE`, but `isClickable()` and the `ACTION_CLICK` path
TalkBack uses don't change, so #31486's behavior stays. Disabled views
are skipped so they keep passing touches to the parent's gestures (same
reason as #29814).

#### Tests

`Issue32226` (Gestures, Android):
- `TapGestureFiresWhenNativeTouchHandlerDoesNotHandleTouch` fails
without the fix ("Not tapped") and passes with it.
- `DoubleTapGestureFiresWhenNativeTouchHandlerDoesNotHandleTouch` fails
without the fix ("Not double tapped") and passes with it.
- `TapOnViewDisabledAtRuntimeReachesParent` (child disabled at runtime,
tap reaches the parent) fails if `UpdateIsEnabled` doesn't restore
`ContextClickable`.
- `TapGestureFiresWithoutNativeTouchHandler` passes with and without it.

No new failures in the `Gestures` category. With TalkBack on, the tap
target still reports `clickable=false`, and focus + double-tap fires
`Tapped`.

### Issues Fixed

Fixes #32226

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 23, 2026
…40531)

<!-- 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!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This PR targets the SR2 release candidate, `candidate/11.0.1xx-sr2`,
because this intermittent failure is the only remaining UI-test failure
on #40116 (UI build 1694858 at candidate `e3c8b2ec`). The test is the
same on `net11` and `main`, so the change applies there too.

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Test-only change to `Issue2241.ChangeOrientationCheckScroll`. Product
code, the host page and the shared Appium helpers are unchanged.

**Root cause: the test reads the layout mid-rotation**

`App.SetOrientationLandscape()` / `SetOrientationPortrait()` return as
soon as the driver accepts the orientation change. They don't wait for
the rotation to finish, which on iOS animates for roughly 300–400 ms.
The test called `GetRect()` immediately after rotating back to portrait,
so it sometimes read an intermediate frame of `MainGrid` instead of the
settled layout.

- Settled portrait layout: `MainGrid` at y=211 with height 400, so
CenterY = **411** (the expected value).
- Values seen mid-animation: **249** and **251** in CI; 211–248 locally.

In the local failing runs, the page source captured at teardown shows
the grid back at x=20, y=211, 335×400 (CenterY 411). The ScrollView
layout settles correctly; only the read was early. This is not a product
regression.

**CI evidence**

- UI build 1694858 (candidate `e3c8b2ec`), `Controls (v18.5)
ScrollView`, run 47329666: `Expected: 411 But was: 249`, then `251` on
the in-job retry.
- 421 iOS ScrollView job runs scanned across `main`, `net11`, inflight,
candidate and unrelated PRs. The same assertion also failed on candidate
build 1684453 (235), #40307 (262) and #40263 (263). It is an
intermittent that occurs on every branch at about 1%, not a candidate
regression.

**Fix**

After each rotation, the new `WaitForMainGridToSettle` helper polls
`MainGrid` every 100 ms until two conditions hold:

1. The rect shows the rotated layout: wider than portrait after going to
landscape, narrower than landscape after going back.
2. The rect has been identical for two consecutive reads.

It fails with the last rect if this doesn't happen within 10 s. The
assertion itself is unchanged: portrait CenterY before and after the
scroll must be equal.

**Causal validation (local, iOS 18.5 iPhone Xs simulator — the CI
configuration)**

`dotnet test
src/Controls/tests/TestCases.iOS.Tests/Controls.TestCases.iOS.Tests.csproj
--no-build --filter "Name=ChangeOrientationCheckScroll"`, repeated in a
loop with `HEADLESS=true`:

| Stage | Test code | Result | Observed CenterY on failure |
| --- | --- | --- | --- |
| Baseline | original | **6 of 15 failed** | 211, 224, 224, 234, 224,
233 |
| Fix | this PR | **20 of 20 passed** | — |
| Trigger removed | original + `Thread.Sleep(3000)` after each rotation
| **12 of 12 passed** | — |
| Fix reverted | original | **9 of 15 failed** | 224, 233, 224, 211,
232, 248, 211, 224, 233 |
| Restored | this PR | **15 of 15 passed** | — |

Adding only a delay after rotating removes the failure, which confirms
the timing cause. The fix doesn't slow the test noticeably: it took
about 20 s per run, as before.

The test also runs on Android. On an Android API 30 emulator (the CI API
level), the fixed test passed 4 of 4 runs (4–7 s each) via `pwsh
.github/scripts/BuildAndRunHostApp.ps1 -Platform android -TestFilter
"Name=ChangeOrientationCheckScroll"`, so the rotation-and-settle wait
also holds there.

### Issues Fixed

Fixes the intermittent `Issue2241.ChangeOrientationCheckScroll` iOS
UI-test failure on #40116. There is no separate issue for it. Related:
#2241.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 23, 2026
…er sets Handled to false (#40307)

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

On Android, the gesture manager subscribes to `View.Touch` and keeps the
touch sequence by setting `e.Handled = true` on `ACTION_DOWN`. .NET for
Android raises every `Touch` subscriber with one shared
`TouchEventArgs`, so a handler added after ours (the workaround from
#23901 (comment))
overwrites it with `false`. Android then falls back to
`View.onTouchEvent`, which only keeps the sequence for clickable views,
so `ACTION_UP` never reaches the gesture detector and the tap is lost.
#29649 hid this by making these views `Clickable`; #31486 removed that
because it broke TalkBack (#31483).

This sets `ContextClickable = true` on enabled views whose touch
sequence our listener consumes (tap, including Span taps, pan, swipe,
pinch, drag; not pointer-only or long-press-only views) and restores the
original value when the gesture is removed, the view is disabled, or the
manager is torn down. `View.onTouchEvent` treats `CONTEXT_CLICKABLE`
like `CLICKABLE`, but `isClickable()` and the `ACTION_CLICK` path
TalkBack uses don't change, so #31486's behavior stays. Disabled views
are skipped so they keep passing touches to the parent's gestures (same
reason as #29814).

#### Tests

`Issue32226` (Gestures, Android):
- `TapGestureFiresWhenNativeTouchHandlerDoesNotHandleTouch` fails
without the fix ("Not tapped") and passes with it.
- `DoubleTapGestureFiresWhenNativeTouchHandlerDoesNotHandleTouch` fails
without the fix ("Not double tapped") and passes with it.
- `TapOnViewDisabledAtRuntimeReachesParent` (child disabled at runtime,
tap reaches the parent) fails if `UpdateIsEnabled` doesn't restore
`ContextClickable`.
- `TapGestureFiresWithoutNativeTouchHandler` passes with and without it.

No new failures in the `Gestures` category. With TalkBack on, the tap
target still reports `clickable=false`, and focus + double-tap fires
`Tapped`.

### Issues Fixed

Fixes #32226

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 23, 2026
…40531)

<!-- 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!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This PR targets the SR2 release candidate, `candidate/11.0.1xx-sr2`,
because this intermittent failure is the only remaining UI-test failure
on #40116 (UI build 1694858 at candidate `e3c8b2ec`). The test is the
same on `net11` and `main`, so the change applies there too.

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Test-only change to `Issue2241.ChangeOrientationCheckScroll`. Product
code, the host page and the shared Appium helpers are unchanged.

**Root cause: the test reads the layout mid-rotation**

`App.SetOrientationLandscape()` / `SetOrientationPortrait()` return as
soon as the driver accepts the orientation change. They don't wait for
the rotation to finish, which on iOS animates for roughly 300–400 ms.
The test called `GetRect()` immediately after rotating back to portrait,
so it sometimes read an intermediate frame of `MainGrid` instead of the
settled layout.

- Settled portrait layout: `MainGrid` at y=211 with height 400, so
CenterY = **411** (the expected value).
- Values seen mid-animation: **249** and **251** in CI; 211–248 locally.

In the local failing runs, the page source captured at teardown shows
the grid back at x=20, y=211, 335×400 (CenterY 411). The ScrollView
layout settles correctly; only the read was early. This is not a product
regression.

**CI evidence**

- UI build 1694858 (candidate `e3c8b2ec`), `Controls (v18.5)
ScrollView`, run 47329666: `Expected: 411 But was: 249`, then `251` on
the in-job retry.
- 421 iOS ScrollView job runs scanned across `main`, `net11`, inflight,
candidate and unrelated PRs. The same assertion also failed on candidate
build 1684453 (235), #40307 (262) and #40263 (263). It is an
intermittent that occurs on every branch at about 1%, not a candidate
regression.

**Fix**

After each rotation, the new `WaitForMainGridToSettle` helper polls
`MainGrid` every 100 ms until two conditions hold:

1. The rect shows the rotated layout: wider than portrait after going to
landscape, narrower than landscape after going back.
2. The rect has been identical for two consecutive reads.

It fails with the last rect if this doesn't happen within 10 s. The
assertion itself is unchanged: portrait CenterY before and after the
scroll must be equal.

**Causal validation (local, iOS 18.5 iPhone Xs simulator — the CI
configuration)**

`dotnet test
src/Controls/tests/TestCases.iOS.Tests/Controls.TestCases.iOS.Tests.csproj
--no-build --filter "Name=ChangeOrientationCheckScroll"`, repeated in a
loop with `HEADLESS=true`:

| Stage | Test code | Result | Observed CenterY on failure |
| --- | --- | --- | --- |
| Baseline | original | **6 of 15 failed** | 211, 224, 224, 234, 224,
233 |
| Fix | this PR | **20 of 20 passed** | — |
| Trigger removed | original + `Thread.Sleep(3000)` after each rotation
| **12 of 12 passed** | — |
| Fix reverted | original | **9 of 15 failed** | 224, 233, 224, 211,
232, 248, 211, 224, 233 |
| Restored | this PR | **15 of 15 passed** | — |

Adding only a delay after rotating removes the failure, which confirms
the timing cause. The fix doesn't slow the test noticeably: it took
about 20 s per run, as before.

The test also runs on Android. On an Android API 30 emulator (the CI API
level), the fixed test passed 4 of 4 runs (4–7 s each) via `pwsh
.github/scripts/BuildAndRunHostApp.ps1 -Platform android -TestFilter
"Name=ChangeOrientationCheckScroll"`, so the rotation-and-settle wait
also holds there.

### Issues Fixed

Fixes the intermittent `Issue2241.ChangeOrientationCheckScroll` iOS
UI-test failure on #40116. There is no separate issue for it. Related:
#2241.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
devanathan-vaithiyanathan pushed a commit to devanathan-vaithiyanathan/maui that referenced this pull request Nov 24, 2026
…otnet#40531)

<!-- 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!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This PR targets the SR2 release candidate, `candidate/11.0.1xx-sr2`,
because this intermittent failure is the only remaining UI-test failure
on dotnet#40116 (UI build 1694858 at candidate `e3c8b2ec`). The test is the
same on `net11` and `main`, so the change applies there too.

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Test-only change to `Issue2241.ChangeOrientationCheckScroll`. Product
code, the host page and the shared Appium helpers are unchanged.

**Root cause: the test reads the layout mid-rotation**

`App.SetOrientationLandscape()` / `SetOrientationPortrait()` return as
soon as the driver accepts the orientation change. They don't wait for
the rotation to finish, which on iOS animates for roughly 300–400 ms.
The test called `GetRect()` immediately after rotating back to portrait,
so it sometimes read an intermediate frame of `MainGrid` instead of the
settled layout.

- Settled portrait layout: `MainGrid` at y=211 with height 400, so
CenterY = **411** (the expected value).
- Values seen mid-animation: **249** and **251** in CI; 211–248 locally.

In the local failing runs, the page source captured at teardown shows
the grid back at x=20, y=211, 335×400 (CenterY 411). The ScrollView
layout settles correctly; only the read was early. This is not a product
regression.

**CI evidence**

- UI build 1694858 (candidate `e3c8b2ec`), `Controls (v18.5)
ScrollView`, run 47329666: `Expected: 411 But was: 249`, then `251` on
the in-job retry.
- 421 iOS ScrollView job runs scanned across `main`, `net11`, inflight,
candidate and unrelated PRs. The same assertion also failed on candidate
build 1684453 (235), dotnet#40307 (262) and dotnet#40263 (263). It is an
intermittent that occurs on every branch at about 1%, not a candidate
regression.

**Fix**

After each rotation, the new `WaitForMainGridToSettle` helper polls
`MainGrid` every 100 ms until two conditions hold:

1. The rect shows the rotated layout: wider than portrait after going to
landscape, narrower than landscape after going back.
2. The rect has been identical for two consecutive reads.

It fails with the last rect if this doesn't happen within 10 s. The
assertion itself is unchanged: portrait CenterY before and after the
scroll must be equal.

**Causal validation (local, iOS 18.5 iPhone Xs simulator — the CI
configuration)**

`dotnet test
src/Controls/tests/TestCases.iOS.Tests/Controls.TestCases.iOS.Tests.csproj
--no-build --filter "Name=ChangeOrientationCheckScroll"`, repeated in a
loop with `HEADLESS=true`:

| Stage | Test code | Result | Observed CenterY on failure |
| --- | --- | --- | --- |
| Baseline | original | **6 of 15 failed** | 211, 224, 224, 234, 224,
233 |
| Fix | this PR | **20 of 20 passed** | — |
| Trigger removed | original + `Thread.Sleep(3000)` after each rotation
| **12 of 12 passed** | — |
| Fix reverted | original | **9 of 15 failed** | 224, 233, 224, 211,
232, 248, 211, 224, 233 |
| Restored | this PR | **15 of 15 passed** | — |

Adding only a delay after rotating removes the failure, which confirms
the timing cause. The fix doesn't slow the test noticeably: it took
about 20 s per run, as before.

The test also runs on Android. On an Android API 30 emulator (the CI API
level), the fixed test passed 4 of 4 runs (4–7 s each) via `pwsh
.github/scripts/BuildAndRunHostApp.ps1 -Platform android -TestFilter
"Name=ChangeOrientationCheckScroll"`, so the rotation-and-settle wait
also holds there.

### Issues Fixed

Fixes the intermittent `Issue2241.ChangeOrientationCheckScroll` iOS
UI-test failure on dotnet#40116. There is no separate issue for it. Related:
dotnet#2241.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@kubaflo kubaflo added this to the .NET 11 SR2 milestone Nov 24, 2026
KarthikRajaKalaimani pushed a commit to KarthikRajaKalaimani/maui that referenced this pull request Nov 26, 2026
…er sets Handled to false (dotnet#40307)

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

On Android, the gesture manager subscribes to `View.Touch` and keeps the
touch sequence by setting `e.Handled = true` on `ACTION_DOWN`. .NET for
Android raises every `Touch` subscriber with one shared
`TouchEventArgs`, so a handler added after ours (the workaround from
dotnet#23901 (comment))
overwrites it with `false`. Android then falls back to
`View.onTouchEvent`, which only keeps the sequence for clickable views,
so `ACTION_UP` never reaches the gesture detector and the tap is lost.
dotnet#29649 hid this by making these views `Clickable`; dotnet#31486 removed that
because it broke TalkBack (dotnet#31483).

This sets `ContextClickable = true` on enabled views whose touch
sequence our listener consumes (tap, including Span taps, pan, swipe,
pinch, drag; not pointer-only or long-press-only views) and restores the
original value when the gesture is removed, the view is disabled, or the
manager is torn down. `View.onTouchEvent` treats `CONTEXT_CLICKABLE`
like `CLICKABLE`, but `isClickable()` and the `ACTION_CLICK` path
TalkBack uses don't change, so dotnet#31486's behavior stays. Disabled views
are skipped so they keep passing touches to the parent's gestures (same
reason as dotnet#29814).

#### Tests

`Issue32226` (Gestures, Android):
- `TapGestureFiresWhenNativeTouchHandlerDoesNotHandleTouch` fails
without the fix ("Not tapped") and passes with it.
- `DoubleTapGestureFiresWhenNativeTouchHandlerDoesNotHandleTouch` fails
without the fix ("Not double tapped") and passes with it.
- `TapOnViewDisabledAtRuntimeReachesParent` (child disabled at runtime,
tap reaches the parent) fails if `UpdateIsEnabled` doesn't restore
`ContextClickable`.
- `TapGestureFiresWithoutNativeTouchHandler` passes with and without it.

No new failures in the `Gestures` category. With TalkBack on, the tap
target still reports `clickable=false`, and focus + double-tap fires
`Tapped`.

### Issues Fixed

Fixes dotnet#32226

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
KarthikRajaKalaimani pushed a commit to KarthikRajaKalaimani/maui that referenced this pull request Nov 26, 2026
…otnet#40531)

<!-- 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!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This PR targets the SR2 release candidate, `candidate/11.0.1xx-sr2`,
because this intermittent failure is the only remaining UI-test failure
on dotnet#40116 (UI build 1694858 at candidate `e3c8b2ec`). The test is the
same on `net11` and `main`, so the change applies there too.

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Test-only change to `Issue2241.ChangeOrientationCheckScroll`. Product
code, the host page and the shared Appium helpers are unchanged.

**Root cause: the test reads the layout mid-rotation**

`App.SetOrientationLandscape()` / `SetOrientationPortrait()` return as
soon as the driver accepts the orientation change. They don't wait for
the rotation to finish, which on iOS animates for roughly 300–400 ms.
The test called `GetRect()` immediately after rotating back to portrait,
so it sometimes read an intermediate frame of `MainGrid` instead of the
settled layout.

- Settled portrait layout: `MainGrid` at y=211 with height 400, so
CenterY = **411** (the expected value).
- Values seen mid-animation: **249** and **251** in CI; 211–248 locally.

In the local failing runs, the page source captured at teardown shows
the grid back at x=20, y=211, 335×400 (CenterY 411). The ScrollView
layout settles correctly; only the read was early. This is not a product
regression.

**CI evidence**

- UI build 1694858 (candidate `e3c8b2ec`), `Controls (v18.5)
ScrollView`, run 47329666: `Expected: 411 But was: 249`, then `251` on
the in-job retry.
- 421 iOS ScrollView job runs scanned across `main`, `net11`, inflight,
candidate and unrelated PRs. The same assertion also failed on candidate
build 1684453 (235), dotnet#40307 (262) and dotnet#40263 (263). It is an
intermittent that occurs on every branch at about 1%, not a candidate
regression.

**Fix**

After each rotation, the new `WaitForMainGridToSettle` helper polls
`MainGrid` every 100 ms until two conditions hold:

1. The rect shows the rotated layout: wider than portrait after going to
landscape, narrower than landscape after going back.
2. The rect has been identical for two consecutive reads.

It fails with the last rect if this doesn't happen within 10 s. The
assertion itself is unchanged: portrait CenterY before and after the
scroll must be equal.

**Causal validation (local, iOS 18.5 iPhone Xs simulator — the CI
configuration)**

`dotnet test
src/Controls/tests/TestCases.iOS.Tests/Controls.TestCases.iOS.Tests.csproj
--no-build --filter "Name=ChangeOrientationCheckScroll"`, repeated in a
loop with `HEADLESS=true`:

| Stage | Test code | Result | Observed CenterY on failure |
| --- | --- | --- | --- |
| Baseline | original | **6 of 15 failed** | 211, 224, 224, 234, 224,
233 |
| Fix | this PR | **20 of 20 passed** | — |
| Trigger removed | original + `Thread.Sleep(3000)` after each rotation
| **12 of 12 passed** | — |
| Fix reverted | original | **9 of 15 failed** | 224, 233, 224, 211,
232, 248, 211, 224, 233 |
| Restored | this PR | **15 of 15 passed** | — |

Adding only a delay after rotating removes the failure, which confirms
the timing cause. The fix doesn't slow the test noticeably: it took
about 20 s per run, as before.

The test also runs on Android. On an Android API 30 emulator (the CI API
level), the fixed test passed 4 of 4 runs (4–7 s each) via `pwsh
.github/scripts/BuildAndRunHostApp.ps1 -Platform android -TestFilter
"Name=ChangeOrientationCheckScroll"`, so the rotation-and-settle wait
also holds there.

### Issues Fixed

Fixes the intermittent `Issue2241.ChangeOrientationCheckScroll` iOS
UI-test failure on dotnet#40116. There is no separate issue for it. Related:
dotnet#2241.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-gestures Gesture types community ✨ Community Contribution platform/android

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants