Skip to content

[Android]Fix keyboard-type flicker when replacing focused ContentView content - #40169

Merged
kubaflo merged 5 commits into
dotnet:net11from
SuthiYuvaraj:Fix-38799
Nov 13, 2026
Merged

kubaflo merged 5 commits into
dotnet:net11from
SuthiYuvaraj:Fix-38799

Conversation

@SuthiYuvaraj

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.

Issue Description

On Android 16, switching between Entries with different keyboard types can briefly display the previous keyboard layout before showing the correct one, causing visible flickering. In the reproduction, each Entry is dynamically added to a ContentView and replaced with a Label when another cell is selected.

Root Cause

RemoveAllViews() detached the focused native EditText without explicitly clearing its focus. Removing a view is not the same as completing a focus transition.

Android updates the keyboard through its input-method system asynchronously. If the outgoing text field is still considered the active input target, the keyboard can temporarily retain its configuration while Android processes detachment, transfers focus, and establishes the incoming Entry’s input connection.

Description of Change

  • Clear native focus from the outgoing ContentView content before calling RemoveAllViews() on Android.
  • Previously, removing content containing a focused Entry could leave stale input-method state. When switching between Entries with different keyboard types, the previous keyboard layout could briefly appear before the correct layout.
  • Explicitly clearing focus before removing the native view ensures that the outgoing Entry relinquishes focus before the next Entry is attached and focused.

Issues Fixed

Fixes #38799

Tested the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Output Screenshot

Before Issue Fix After Issue Fix
Screen.Recording.2026-11-12.at.3.09.04.PM.mov
Screen.Recording.2026-11-12.at.3.07.00.PM.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 -- 40169

Or

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

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

This comment has been minimized.

@SuthiYuvaraj SuthiYuvaraj changed the title Fix 38799 [WIP][Android]Fix keyboard-type flicker when replacing focused ContentView content Nov 12, 2026
@SuthiYuvaraj SuthiYuvaraj added the community ✨ Community Contribution label Nov 12, 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 12, 2026
@kubaflo

kubaflo commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

/rebase

@github-actions

Copy link
Copy Markdown
Contributor

Unable to rebase this branch automatically. It may have conflicts with its base branch, or the PR author has not allowed maintainer edits. Please rebase manually.

@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 — 3 findings

Reviewed commit 2606537.

See inline comments for details.

if (PlatformView is null || VirtualView is null)
return;

PlatformView.UpdateKeyboard(VirtualView);

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.

[moderate] Handler Mapper and Property Patterns - Reapplying the keyboard here overwrites custom numeric KeyListeners after mapper initialization. UpdateKeyboard calls SetInputType, which unconditionally installs LocalizedDigitsKeyListener for Keyboard.Numeric, without rerunning the customization. The existing Issue21109DecimalEntry is a concrete affected case: its AppendToMapping installs Issue21109NumericKeyListener before attachment, but this callback replaces it, losing its accepted characters and OnKeyDown handling and regressing the scenario addressed by #22546. Preserve the installed customization when refreshing the keyboard. The new attachment-time call in EntryHandler2 has the same mapper-bypass problem.

@MauiBot

MauiBot commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@SuthiYuvaraj — existing-test verification for commit 26065376.

Result PASSED Platform Android Commit 26065376


🧪 Gate analysis — click to expand

✅ Passed. The selected verification satisfied the gate's passing conditions. Unmatched, skipped, or inconclusive groups are not passing evidence.

🖥 UI tests
Test group Without fix With fix
Issue38799 ✅ Failed as expected (554s) ✅ Passed (1472s)
Execution log excerpts

Without fix Issue38799

     at Microsoft.Maui.TestCases.Tests.Issues.Issue38799.ReplacingTextEntryRelinquishesFocusBeforeRemoval() in /_/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue38799.cs:line 30

With fix Issue38799

/home/vsts/work/1/s/.dotnet/packs/Microsoft.Android.Sdk.Linux/37.2.15/tools/Xamarin.Android.Common.Debugging.targets(378,5): error ADB0010: Timed out waiting for data from device. [/home/vsts/work/1/s/src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj::TargetFramework=net11.0-android]
/home/vsts/work/1/s/.dotnet/packs/Microsoft.Android.Sdk.Linux/37.2.15/tools/Xamarin.Android.Common.Debugging.targets(378,5): error ADB0010: adb: failed to install /home/vsts/work/1/s/artifacts/bin/Controls.TestCases.HostApp/Debug/net11.0-android/com.microsoft.maui.uitests-Signed.apk: cmd: Failure calling service package: Broken pipe (32) [/home/vsts/work/1/s/src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj::TargetFramework=net11.0-android]
/home/vsts/work/1/s/.dotnet/packs/Microsoft.Android.Sdk.Linux/37.2.15/tools/Xamarin.Android.Common.Debugging.targets(378,5): error ADB0010: ADB transport recovery: [/home/vsts/work/1/s/src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj::TargetFramework=net11.0-android]
/home/vsts/work/1/s/.dotnet/packs/Microsoft.Android.Sdk.Linux/37.2.15/tools/Xamarin.Android.Common.Debugging.targets(378,5): error ADB0010: Recovery failed: System.TimeoutException: Timed out waiting for the Android package manager on device 'emulator-5554' after 10 seconds. Last response: exit code 20: cmd: Can't find service: package [/home/vsts/work/1/s/src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj::TargetFramework=net11.0-android]
/home/vsts/work/1/s/.dotnet/packs/Microsoft.Android.Sdk.Linux/37.2.15/tools/Xamarin.Android.Common.Debugging.targets(378,5): error ADB0010:    at Xamarin.Android.Tools.AdbRunner.WaitForPackageManagerAsync(String serial, Nullable`1 timeout, TimeSpan pollInterval, CancellationToken cancellationToken) [/home/vsts/work/1/s/src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj::TargetFramework=net11.0-android]
/home/vsts/work/1/s/.dotnet/packs/Microsoft.Andr

PR head: 26065376.

Without-fix baseline: 9291bfb2.

@MauiBot MauiBot added s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) and removed s/agent-review-in-progress AI review is currently running for this PR labels Nov 12, 2026
@SuthiYuvaraj
SuthiYuvaraj changed the base branch from main to net11 November 12, 2026 14:06
@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 13, 2026
@kubaflo

kubaflo commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

/rebase

@azure-pipelines

This comment has been minimized.

@MauiBot

MauiBot commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@SuthiYuvaraj — 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 13, 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 12051ee.

@sheiksyedm
sheiksyedm marked this pull request as ready for review November 13, 2026 14:26
@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 13, 2026
@MauiBot

MauiBot commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@SuthiYuvaraj — 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 13, 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 12051ee.

@kubaflo
kubaflo merged commit b2d3141 into dotnet:net11 Nov 13, 2026
53 of 175 checks passed
KitKeen pushed a commit to KitKeen/maui that referenced this pull request Nov 14, 2026
… content (dotnet#40169)

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

- [ ] 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.

### Issue Description

On Android 16, switching between Entries with different keyboard types
can briefly display the previous keyboard layout before showing the
correct one, causing visible flickering. In the reproduction, each Entry
is dynamically added to a ContentView and replaced with a Label when
another cell is selected.

### Root Cause

RemoveAllViews() detached the focused native EditText without explicitly
clearing its focus. Removing a view is not the same as completing a
focus transition.

Android updates the keyboard through its input-method system
asynchronously. If the outgoing text field is still considered the
active input target, the keyboard can temporarily retain its
configuration while Android processes detachment, transfers focus, and
establishes the incoming Entry’s input connection.


### Description of Change

- Clear native focus from the outgoing ContentView content before
calling RemoveAllViews() on Android.
- Previously, removing content containing a focused Entry could leave
stale input-method state. When switching between Entries with different
keyboard types, the previous keyboard layout could briefly appear before
the correct layout.
- Explicitly clearing focus before removing the native view ensures that
the outgoing Entry relinquishes focus before the next Entry is attached
and focused.


### Issues Fixed
Fixes dotnet#38799

### Tested the behaviour in the following platforms
- [x] Android
- [ ] Windows
- [ ] iOS
- [ ] Mac

### Output Screenshot
Before Issue Fix | After Issue Fix |
|----------|----------|
|<video width="300" height="600" alt="Before Fix"
src="https://github.com/user-attachments/assets/62b49b56-86e3-48e8-9ae1-19e92106f5b0">|<video
width="100" height="100" alt="After Fix"
src="https://github.com/user-attachments/assets/55caabe9-2021-43c0-9407-31bbad08db4c">|

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 14, 2026
<!-- 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).

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.

This is an explicitly coordinated release-candidate repair for #40116,
targeting the designated `candidate/11.0.1xx-sr2` branch.

### Description of Change

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

Only post the explicit soft-keyboard request from
`TextViewExtensions.Focus` when Android's native `OnCheckIsTextEditor()`
returns true, while preserving the existing `ShowSoftInputOnFocus` check
and normal focus request.

**Root cause:** #40191 intentionally keeps read-only inputs focusable
and hides an existing keyboard in the native focus-change handler.
However, the shared programmatic-focus callback subsequently posts
`ShowSoftInput` even when the native input has `KeyListener = null`,
`InputType = 0`, and `OnCheckIsTextEditor() == false`. This reopens the
keyboard. In the unchanged
`VerifyEditorSelectionLengthWhenIsReadOnlyTrue` test, the sample's
Update Cursor Selection button programmatically focuses the read-only
Editor; the keyboard then obscures `SelectionLengthEntry`, causing the
timeout at line 480.

Native tracing on API 30 confirmed the Editor is genuinely read-only and
remains focusable/focused while the IME changes from hidden to visible.
A diagnostic-only control removing the explicit keyboard-show trigger
clears the unchanged test. The fix does not revert read-only
focusability or alter cursor/selection mapping. No timeouts, retry
budgets, filters, or screenshot tolerances are changed; existing
assertions are retained and focus assertions are added.

Extend the existing Issue6250 page/tests rather than adding a fixture:
exercise touch and programmatic focus for read-only Entry, Editor, and
SearchBar. Each case first proves an editable Entry shows the keyboard;
the programmatic cases use `Focus()` for that positive control too. All
cases assert that the intended read-only control actually receives focus
and the keyboard disappears. The original Editor feature tests remain
unchanged.

**Local causal validation:** Android API 30, Nexus 5X, 1080x1920, 420
dpi, ARM64, CoreCLR 11.0.0, SDK 11.0.100.

| Phase | Result |
| --- | --- |
| Unchanged original read-only Editor pair | Selection-length case times
out at the same line as CI; cursor-position case passes |
| Diagnostic trigger-removed control | Original pair: 2 passed |
| Fix applied | Original pair plus six focus cases: 8 passed |
| Only production guard reverted, final test bodies retained | 4 failed
/ 4 passed: original selection timeout and all three read-only
programmatic cases fail |
| Guard restored, no diagnostic app instrumentation | Same eight cases:
8 passed |
| Expanded selector including both Editor fixture names and Issue6250 |
93 total: 62 passed, 3 existing skips, 28 failed solely because
Material3 API-30 baseline snapshots are absent; no snapshots or filters
changed |
| Pushed commit rebuilt and identical expanded selector repeated | 93
total: 62 passed, 3 existing skips, 28 missing-baseline failures;
original Editor fixture 56 passed / 3 skips and Issue6250 6 passed |

Within that expanded run, the original Editor fixture is **56 passed / 3
existing skips** and Issue6250 is **6 passed**. The Material3 failures
are explicit validation limitations, not a green full-suite claim: those
snapshots exist under `android-notch-36`, not the API-30 `android`
directory.

The failing CI environment uses x86_64/CoreCLR 11.0.1/servicing SDK
11.0.101. Local ARM64 validation is not a claim that the exact CI
runtime or other platforms have passed. CI requests remain with the
coordinating maintainer/session. No manual CI or review triggers were
submitted.

Searched open and recently merged PRs for the failure, native
text-editor check, and explicit keyboard-show mechanism; #40191 is the
preceding focusability change, not a duplicate repair. #40169 changes
ContentView handling, not this focus path.

#### Exact commands and results

Run from the repository root using the local SDK/runtime and owned
emulator described above. Absolute paths below identify retained
diagnostic results; none of those diagnostic files is part of the PR.

**Passed: 0 warnings, 0 errors.**

```bash
dotnet build Microsoft.Maui.BuildTasks.slnf -c Debug -p:IncludeAndroidTargetFrameworks=true -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -v:q
```

**Passed, including the post-push build: 0 warnings, 0 errors.**

```bash
dotnet build src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj -c Debug -f net11.0-android -p:RuntimeIdentifier=android-arm64 -p:EmbedAssembliesIntoApk=true -p:UseMonoRuntime=false -p:IncludeAndroidTargetFrameworks=true -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -v:q
```

**Passed, including the post-push build: 0 warnings, 0 errors. The
external targets file changes only the task-owned Appium endpoint.**

```bash
dotnet build src/Controls/tests/TestCases.Android.Tests/Controls.TestCases.Android.Tests.csproj -c Debug -p:IncludeAndroidTargetFrameworks=true -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -p:CustomAfterMicrosoftCommonTargets=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/private-appium.targets -v:q
```

**Passed (exit 0); only these three changed C# files were included.**

```bash
dotnet format Microsoft.Maui.sln --no-restore --exclude Templates/src --exclude-diagnostics CA1822 --include src/Core/src/Platform/Android/TextViewExtensions.cs src/Controls/tests/TestCases.HostApp/Issues/Issue6250.cs src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue6250.cs --verbosity quiet
```

**Expected red with only the production guard removed: 4 failed / 4
passed / 0 skipped.**

```bash
DEVICE_UDID=emulator-5576 ANDROID_SERIAL=emulator-5576 PLATFORM_VERSION=11 DEVICE_SKIN='Nexus 5X' APPIUM_LOG_FILE=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-reverted-appium.log dotnet vstest artifacts/bin/Controls.TestCases.Android.Tests/Debug/net11.0/Controls.TestCases.Android.Tests.dll '--TestCaseFilter:FullyQualifiedName~VerifyEditorSelectionLengthWhenIsReadOnlyTrue|FullyQualifiedName~VerifyEditorCursorPositionWhenIsReadOnlyTrue|FullyQualifiedName~Microsoft.Maui.TestCases.Tests.Issues.Issue6250' '--logger:trx;LogFileName=final-reverted.trx' --ResultsDirectory:/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-reverted
```

**Guard restored: 8 passed / 0 failed / 0 skipped, including editable
programmatic-focus positive controls.**

```bash
DEVICE_UDID=emulator-5576 ANDROID_SERIAL=emulator-5576 PLATFORM_VERSION=11 DEVICE_SKIN='Nexus 5X' APPIUM_LOG_FILE=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-restored-appium.log dotnet vstest artifacts/bin/Controls.TestCases.Android.Tests/Debug/net11.0/Controls.TestCases.Android.Tests.dll '--TestCaseFilter:FullyQualifiedName~VerifyEditorSelectionLengthWhenIsReadOnlyTrue|FullyQualifiedName~VerifyEditorCursorPositionWhenIsReadOnlyTrue|FullyQualifiedName~Microsoft.Maui.TestCases.Tests.Issues.Issue6250' '--logger:trx;LogFileName=final-restored.trx' --ResultsDirectory:/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-restored
```

**Post-push full selector on a401a45:
exit 1, 62 passed / 28 failed / 3 existing skips / 93 total. Every
failure is a missing API-30 Material3 baseline; none is silently
excluded.**

```bash
DEVICE_UDID=emulator-5576 ANDROID_SERIAL=emulator-5576 PLATFORM_VERSION=11 DEVICE_SKIN='Nexus 5X' APPIUM_LOG_FILE=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/postpush-appium.log dotnet vstest artifacts/bin/Controls.TestCases.Android.Tests/Debug/net11.0/Controls.TestCases.Android.Tests.dll '--TestCaseFilter:FullyQualifiedName~EditorFeatureTests|FullyQualifiedName~Microsoft.Maui.TestCases.Tests.Issues.Issue6250' '--logger:trx;LogFileName=postpush.trx' --ResultsDirectory:/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/postpush
```

### 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. -->

Relates to #40116 and #40191. Repairs the independent Editor timeout
observed in the validation of #40248; it does not change Issue7556 or
attribute this failure to that PR's implementation.

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 16, 2026
<!-- 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).

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.

This is an explicitly coordinated release-candidate repair for #40116,
targeting the designated `candidate/11.0.1xx-sr2` branch.

### Description of Change

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

Only post the explicit soft-keyboard request from
`TextViewExtensions.Focus` when Android's native `OnCheckIsTextEditor()`
returns true, while preserving the existing `ShowSoftInputOnFocus` check
and normal focus request.

**Root cause:** #40191 intentionally keeps read-only inputs focusable
and hides an existing keyboard in the native focus-change handler.
However, the shared programmatic-focus callback subsequently posts
`ShowSoftInput` even when the native input has `KeyListener = null`,
`InputType = 0`, and `OnCheckIsTextEditor() == false`. This reopens the
keyboard. In the unchanged
`VerifyEditorSelectionLengthWhenIsReadOnlyTrue` test, the sample's
Update Cursor Selection button programmatically focuses the read-only
Editor; the keyboard then obscures `SelectionLengthEntry`, causing the
timeout at line 480.

Native tracing on API 30 confirmed the Editor is genuinely read-only and
remains focusable/focused while the IME changes from hidden to visible.
A diagnostic-only control removing the explicit keyboard-show trigger
clears the unchanged test. The fix does not revert read-only
focusability or alter cursor/selection mapping. No timeouts, retry
budgets, filters, or screenshot tolerances are changed; existing
assertions are retained and focus assertions are added.

Extend the existing Issue6250 page/tests rather than adding a fixture:
exercise touch and programmatic focus for read-only Entry, Editor, and
SearchBar. Each case first proves an editable Entry shows the keyboard;
the programmatic cases use `Focus()` for that positive control too. All
cases assert that the intended read-only control actually receives focus
and the keyboard disappears. The original Editor feature tests remain
unchanged.

**Local causal validation:** Android API 30, Nexus 5X, 1080x1920, 420
dpi, ARM64, CoreCLR 11.0.0, SDK 11.0.100.

| Phase | Result |
| --- | --- |
| Unchanged original read-only Editor pair | Selection-length case times
out at the same line as CI; cursor-position case passes |
| Diagnostic trigger-removed control | Original pair: 2 passed |
| Fix applied | Original pair plus six focus cases: 8 passed |
| Only production guard reverted, final test bodies retained | 4 failed
/ 4 passed: original selection timeout and all three read-only
programmatic cases fail |
| Guard restored, no diagnostic app instrumentation | Same eight cases:
8 passed |
| Expanded selector including both Editor fixture names and Issue6250 |
93 total: 62 passed, 3 existing skips, 28 failed solely because
Material3 API-30 baseline snapshots are absent; no snapshots or filters
changed |
| Pushed commit rebuilt and identical expanded selector repeated | 93
total: 62 passed, 3 existing skips, 28 missing-baseline failures;
original Editor fixture 56 passed / 3 skips and Issue6250 6 passed |

Within that expanded run, the original Editor fixture is **56 passed / 3
existing skips** and Issue6250 is **6 passed**. The Material3 failures
are explicit validation limitations, not a green full-suite claim: those
snapshots exist under `android-notch-36`, not the API-30 `android`
directory.

The failing CI environment uses x86_64/CoreCLR 11.0.1/servicing SDK
11.0.101. Local ARM64 validation is not a claim that the exact CI
runtime or other platforms have passed. CI requests remain with the
coordinating maintainer/session. No manual CI or review triggers were
submitted.

Searched open and recently merged PRs for the failure, native
text-editor check, and explicit keyboard-show mechanism; #40191 is the
preceding focusability change, not a duplicate repair. #40169 changes
ContentView handling, not this focus path.

#### Exact commands and results

Run from the repository root using the local SDK/runtime and owned
emulator described above. Absolute paths below identify retained
diagnostic results; none of those diagnostic files is part of the PR.

**Passed: 0 warnings, 0 errors.**

```bash
dotnet build Microsoft.Maui.BuildTasks.slnf -c Debug -p:IncludeAndroidTargetFrameworks=true -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -v:q
```

**Passed, including the post-push build: 0 warnings, 0 errors.**

```bash
dotnet build src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj -c Debug -f net11.0-android -p:RuntimeIdentifier=android-arm64 -p:EmbedAssembliesIntoApk=true -p:UseMonoRuntime=false -p:IncludeAndroidTargetFrameworks=true -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -v:q
```

**Passed, including the post-push build: 0 warnings, 0 errors. The
external targets file changes only the task-owned Appium endpoint.**

```bash
dotnet build src/Controls/tests/TestCases.Android.Tests/Controls.TestCases.Android.Tests.csproj -c Debug -p:IncludeAndroidTargetFrameworks=true -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -p:CustomAfterMicrosoftCommonTargets=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/private-appium.targets -v:q
```

**Passed (exit 0); only these three changed C# files were included.**

```bash
dotnet format Microsoft.Maui.sln --no-restore --exclude Templates/src --exclude-diagnostics CA1822 --include src/Core/src/Platform/Android/TextViewExtensions.cs src/Controls/tests/TestCases.HostApp/Issues/Issue6250.cs src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue6250.cs --verbosity quiet
```

**Expected red with only the production guard removed: 4 failed / 4
passed / 0 skipped.**

```bash
DEVICE_UDID=emulator-5576 ANDROID_SERIAL=emulator-5576 PLATFORM_VERSION=11 DEVICE_SKIN='Nexus 5X' APPIUM_LOG_FILE=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-reverted-appium.log dotnet vstest artifacts/bin/Controls.TestCases.Android.Tests/Debug/net11.0/Controls.TestCases.Android.Tests.dll '--TestCaseFilter:FullyQualifiedName~VerifyEditorSelectionLengthWhenIsReadOnlyTrue|FullyQualifiedName~VerifyEditorCursorPositionWhenIsReadOnlyTrue|FullyQualifiedName~Microsoft.Maui.TestCases.Tests.Issues.Issue6250' '--logger:trx;LogFileName=final-reverted.trx' --ResultsDirectory:/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-reverted
```

**Guard restored: 8 passed / 0 failed / 0 skipped, including editable
programmatic-focus positive controls.**

```bash
DEVICE_UDID=emulator-5576 ANDROID_SERIAL=emulator-5576 PLATFORM_VERSION=11 DEVICE_SKIN='Nexus 5X' APPIUM_LOG_FILE=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-restored-appium.log dotnet vstest artifacts/bin/Controls.TestCases.Android.Tests/Debug/net11.0/Controls.TestCases.Android.Tests.dll '--TestCaseFilter:FullyQualifiedName~VerifyEditorSelectionLengthWhenIsReadOnlyTrue|FullyQualifiedName~VerifyEditorCursorPositionWhenIsReadOnlyTrue|FullyQualifiedName~Microsoft.Maui.TestCases.Tests.Issues.Issue6250' '--logger:trx;LogFileName=final-restored.trx' --ResultsDirectory:/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-restored
```

**Post-push full selector on a401a45:
exit 1, 62 passed / 28 failed / 3 existing skips / 93 total. Every
failure is a missing API-30 Material3 baseline; none is silently
excluded.**

```bash
DEVICE_UDID=emulator-5576 ANDROID_SERIAL=emulator-5576 PLATFORM_VERSION=11 DEVICE_SKIN='Nexus 5X' APPIUM_LOG_FILE=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/postpush-appium.log dotnet vstest artifacts/bin/Controls.TestCases.Android.Tests/Debug/net11.0/Controls.TestCases.Android.Tests.dll '--TestCaseFilter:FullyQualifiedName~EditorFeatureTests|FullyQualifiedName~Microsoft.Maui.TestCases.Tests.Issues.Issue6250' '--logger:trx;LogFileName=postpush.trx' --ResultsDirectory:/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/postpush
```

### 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. -->

Relates to #40116 and #40191. Repairs the independent Editor timeout
observed in the validation of #40248; it does not change Issue7556 or
attribute this failure to that PR's implementation.

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Vignesh-SF3580 pushed a commit to Vignesh-SF3580/maui that referenced this pull request Nov 16, 2026
… content (dotnet#40169)

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

- [ ] 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.

### Issue Description

On Android 16, switching between Entries with different keyboard types
can briefly display the previous keyboard layout before showing the
correct one, causing visible flickering. In the reproduction, each Entry
is dynamically added to a ContentView and replaced with a Label when
another cell is selected.

### Root Cause

RemoveAllViews() detached the focused native EditText without explicitly
clearing its focus. Removing a view is not the same as completing a
focus transition.

Android updates the keyboard through its input-method system
asynchronously. If the outgoing text field is still considered the
active input target, the keyboard can temporarily retain its
configuration while Android processes detachment, transfers focus, and
establishes the incoming Entry’s input connection.


### Description of Change

- Clear native focus from the outgoing ContentView content before
calling RemoveAllViews() on Android.
- Previously, removing content containing a focused Entry could leave
stale input-method state. When switching between Entries with different
keyboard types, the previous keyboard layout could briefly appear before
the correct layout.
- Explicitly clearing focus before removing the native view ensures that
the outgoing Entry relinquishes focus before the next Entry is attached
and focused.


### Issues Fixed
Fixes dotnet#38799

### Tested the behaviour in the following platforms
- [x] Android
- [ ] Windows
- [ ] iOS
- [ ] Mac

### Output Screenshot
Before Issue Fix | After Issue Fix |
|----------|----------|
|<video width="300" height="600" alt="Before Fix"
src="https://github.com/user-attachments/assets/62b49b56-86e3-48e8-9ae1-19e92106f5b0">|<video
width="100" height="100" alt="After Fix"
src="https://github.com/user-attachments/assets/55caabe9-2021-43c0-9407-31bbad08db4c">|

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 16, 2026
<!-- 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).

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.

This is an explicitly coordinated release-candidate repair for #40116,
targeting the designated `candidate/11.0.1xx-sr2` branch.

### Description of Change

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

Only post the explicit soft-keyboard request from
`TextViewExtensions.Focus` when Android's native `OnCheckIsTextEditor()`
returns true, while preserving the existing `ShowSoftInputOnFocus` check
and normal focus request.

**Root cause:** #40191 intentionally keeps read-only inputs focusable
and hides an existing keyboard in the native focus-change handler.
However, the shared programmatic-focus callback subsequently posts
`ShowSoftInput` even when the native input has `KeyListener = null`,
`InputType = 0`, and `OnCheckIsTextEditor() == false`. This reopens the
keyboard. In the unchanged
`VerifyEditorSelectionLengthWhenIsReadOnlyTrue` test, the sample's
Update Cursor Selection button programmatically focuses the read-only
Editor; the keyboard then obscures `SelectionLengthEntry`, causing the
timeout at line 480.

Native tracing on API 30 confirmed the Editor is genuinely read-only and
remains focusable/focused while the IME changes from hidden to visible.
A diagnostic-only control removing the explicit keyboard-show trigger
clears the unchanged test. The fix does not revert read-only
focusability or alter cursor/selection mapping. No timeouts, retry
budgets, filters, or screenshot tolerances are changed; existing
assertions are retained and focus assertions are added.

Extend the existing Issue6250 page/tests rather than adding a fixture:
exercise touch and programmatic focus for read-only Entry, Editor, and
SearchBar. Each case first proves an editable Entry shows the keyboard;
the programmatic cases use `Focus()` for that positive control too. All
cases assert that the intended read-only control actually receives focus
and the keyboard disappears. The original Editor feature tests remain
unchanged.

**Local causal validation:** Android API 30, Nexus 5X, 1080x1920, 420
dpi, ARM64, CoreCLR 11.0.0, SDK 11.0.100.

| Phase | Result |
| --- | --- |
| Unchanged original read-only Editor pair | Selection-length case times
out at the same line as CI; cursor-position case passes |
| Diagnostic trigger-removed control | Original pair: 2 passed |
| Fix applied | Original pair plus six focus cases: 8 passed |
| Only production guard reverted, final test bodies retained | 4 failed
/ 4 passed: original selection timeout and all three read-only
programmatic cases fail |
| Guard restored, no diagnostic app instrumentation | Same eight cases:
8 passed |
| Expanded selector including both Editor fixture names and Issue6250 |
93 total: 62 passed, 3 existing skips, 28 failed solely because
Material3 API-30 baseline snapshots are absent; no snapshots or filters
changed |
| Pushed commit rebuilt and identical expanded selector repeated | 93
total: 62 passed, 3 existing skips, 28 missing-baseline failures;
original Editor fixture 56 passed / 3 skips and Issue6250 6 passed |

Within that expanded run, the original Editor fixture is **56 passed / 3
existing skips** and Issue6250 is **6 passed**. The Material3 failures
are explicit validation limitations, not a green full-suite claim: those
snapshots exist under `android-notch-36`, not the API-30 `android`
directory.

The failing CI environment uses x86_64/CoreCLR 11.0.1/servicing SDK
11.0.101. Local ARM64 validation is not a claim that the exact CI
runtime or other platforms have passed. CI requests remain with the
coordinating maintainer/session. No manual CI or review triggers were
submitted.

Searched open and recently merged PRs for the failure, native
text-editor check, and explicit keyboard-show mechanism; #40191 is the
preceding focusability change, not a duplicate repair. #40169 changes
ContentView handling, not this focus path.

#### Exact commands and results

Run from the repository root using the local SDK/runtime and owned
emulator described above. Absolute paths below identify retained
diagnostic results; none of those diagnostic files is part of the PR.

**Passed: 0 warnings, 0 errors.**

```bash
dotnet build Microsoft.Maui.BuildTasks.slnf -c Debug -p:IncludeAndroidTargetFrameworks=true -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -v:q
```

**Passed, including the post-push build: 0 warnings, 0 errors.**

```bash
dotnet build src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj -c Debug -f net11.0-android -p:RuntimeIdentifier=android-arm64 -p:EmbedAssembliesIntoApk=true -p:UseMonoRuntime=false -p:IncludeAndroidTargetFrameworks=true -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -v:q
```

**Passed, including the post-push build: 0 warnings, 0 errors. The
external targets file changes only the task-owned Appium endpoint.**

```bash
dotnet build src/Controls/tests/TestCases.Android.Tests/Controls.TestCases.Android.Tests.csproj -c Debug -p:IncludeAndroidTargetFrameworks=true -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -p:CustomAfterMicrosoftCommonTargets=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/private-appium.targets -v:q
```

**Passed (exit 0); only these three changed C# files were included.**

```bash
dotnet format Microsoft.Maui.sln --no-restore --exclude Templates/src --exclude-diagnostics CA1822 --include src/Core/src/Platform/Android/TextViewExtensions.cs src/Controls/tests/TestCases.HostApp/Issues/Issue6250.cs src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue6250.cs --verbosity quiet
```

**Expected red with only the production guard removed: 4 failed / 4
passed / 0 skipped.**

```bash
DEVICE_UDID=emulator-5576 ANDROID_SERIAL=emulator-5576 PLATFORM_VERSION=11 DEVICE_SKIN='Nexus 5X' APPIUM_LOG_FILE=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-reverted-appium.log dotnet vstest artifacts/bin/Controls.TestCases.Android.Tests/Debug/net11.0/Controls.TestCases.Android.Tests.dll '--TestCaseFilter:FullyQualifiedName~VerifyEditorSelectionLengthWhenIsReadOnlyTrue|FullyQualifiedName~VerifyEditorCursorPositionWhenIsReadOnlyTrue|FullyQualifiedName~Microsoft.Maui.TestCases.Tests.Issues.Issue6250' '--logger:trx;LogFileName=final-reverted.trx' --ResultsDirectory:/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-reverted
```

**Guard restored: 8 passed / 0 failed / 0 skipped, including editable
programmatic-focus positive controls.**

```bash
DEVICE_UDID=emulator-5576 ANDROID_SERIAL=emulator-5576 PLATFORM_VERSION=11 DEVICE_SKIN='Nexus 5X' APPIUM_LOG_FILE=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-restored-appium.log dotnet vstest artifacts/bin/Controls.TestCases.Android.Tests/Debug/net11.0/Controls.TestCases.Android.Tests.dll '--TestCaseFilter:FullyQualifiedName~VerifyEditorSelectionLengthWhenIsReadOnlyTrue|FullyQualifiedName~VerifyEditorCursorPositionWhenIsReadOnlyTrue|FullyQualifiedName~Microsoft.Maui.TestCases.Tests.Issues.Issue6250' '--logger:trx;LogFileName=final-restored.trx' --ResultsDirectory:/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-restored
```

**Post-push full selector on a401a45:
exit 1, 62 passed / 28 failed / 3 existing skips / 93 total. Every
failure is a missing API-30 Material3 baseline; none is silently
excluded.**

```bash
DEVICE_UDID=emulator-5576 ANDROID_SERIAL=emulator-5576 PLATFORM_VERSION=11 DEVICE_SKIN='Nexus 5X' APPIUM_LOG_FILE=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/postpush-appium.log dotnet vstest artifacts/bin/Controls.TestCases.Android.Tests/Debug/net11.0/Controls.TestCases.Android.Tests.dll '--TestCaseFilter:FullyQualifiedName~EditorFeatureTests|FullyQualifiedName~Microsoft.Maui.TestCases.Tests.Issues.Issue6250' '--logger:trx;LogFileName=postpush.trx' --ResultsDirectory:/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/postpush
```

### 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. -->

Relates to #40116 and #40191. Repairs the independent Editor timeout
observed in the validation of #40248; it does not change Issue7556 or
attribute this failure to that PR's implementation.

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
github-actions Bot pushed a commit to MykhailoDav/maui that referenced this pull request Nov 16, 2026
… content (dotnet#40169)

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

- [ ] 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.

### Issue Description

On Android 16, switching between Entries with different keyboard types
can briefly display the previous keyboard layout before showing the
correct one, causing visible flickering. In the reproduction, each Entry
is dynamically added to a ContentView and replaced with a Label when
another cell is selected.

### Root Cause

RemoveAllViews() detached the focused native EditText without explicitly
clearing its focus. Removing a view is not the same as completing a
focus transition.

Android updates the keyboard through its input-method system
asynchronously. If the outgoing text field is still considered the
active input target, the keyboard can temporarily retain its
configuration while Android processes detachment, transfers focus, and
establishes the incoming Entry’s input connection.


### Description of Change

- Clear native focus from the outgoing ContentView content before
calling RemoveAllViews() on Android.
- Previously, removing content containing a focused Entry could leave
stale input-method state. When switching between Entries with different
keyboard types, the previous keyboard layout could briefly appear before
the correct layout.
- Explicitly clearing focus before removing the native view ensures that
the outgoing Entry relinquishes focus before the next Entry is attached
and focused.


### Issues Fixed
Fixes dotnet#38799

### Tested the behaviour in the following platforms
- [x] Android
- [ ] Windows
- [ ] iOS
- [ ] Mac

### Output Screenshot
Before Issue Fix | After Issue Fix |
|----------|----------|
|<video width="300" height="600" alt="Before Fix"
src="https://github.com/user-attachments/assets/62b49b56-86e3-48e8-9ae1-19e92106f5b0">|<video
width="100" height="100" alt="After Fix"
src="https://github.com/user-attachments/assets/55caabe9-2021-43c0-9407-31bbad08db4c">|

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 17, 2026
<!-- 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).

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.

This is an explicitly coordinated release-candidate repair for #40116,
targeting the designated `candidate/11.0.1xx-sr2` branch.

### Description of Change

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

Only post the explicit soft-keyboard request from
`TextViewExtensions.Focus` when Android's native `OnCheckIsTextEditor()`
returns true, while preserving the existing `ShowSoftInputOnFocus` check
and normal focus request.

**Root cause:** #40191 intentionally keeps read-only inputs focusable
and hides an existing keyboard in the native focus-change handler.
However, the shared programmatic-focus callback subsequently posts
`ShowSoftInput` even when the native input has `KeyListener = null`,
`InputType = 0`, and `OnCheckIsTextEditor() == false`. This reopens the
keyboard. In the unchanged
`VerifyEditorSelectionLengthWhenIsReadOnlyTrue` test, the sample's
Update Cursor Selection button programmatically focuses the read-only
Editor; the keyboard then obscures `SelectionLengthEntry`, causing the
timeout at line 480.

Native tracing on API 30 confirmed the Editor is genuinely read-only and
remains focusable/focused while the IME changes from hidden to visible.
A diagnostic-only control removing the explicit keyboard-show trigger
clears the unchanged test. The fix does not revert read-only
focusability or alter cursor/selection mapping. No timeouts, retry
budgets, filters, or screenshot tolerances are changed; existing
assertions are retained and focus assertions are added.

Extend the existing Issue6250 page/tests rather than adding a fixture:
exercise touch and programmatic focus for read-only Entry, Editor, and
SearchBar. Each case first proves an editable Entry shows the keyboard;
the programmatic cases use `Focus()` for that positive control too. All
cases assert that the intended read-only control actually receives focus
and the keyboard disappears. The original Editor feature tests remain
unchanged.

**Local causal validation:** Android API 30, Nexus 5X, 1080x1920, 420
dpi, ARM64, CoreCLR 11.0.0, SDK 11.0.100.

| Phase | Result |
| --- | --- |
| Unchanged original read-only Editor pair | Selection-length case times
out at the same line as CI; cursor-position case passes |
| Diagnostic trigger-removed control | Original pair: 2 passed |
| Fix applied | Original pair plus six focus cases: 8 passed |
| Only production guard reverted, final test bodies retained | 4 failed
/ 4 passed: original selection timeout and all three read-only
programmatic cases fail |
| Guard restored, no diagnostic app instrumentation | Same eight cases:
8 passed |
| Expanded selector including both Editor fixture names and Issue6250 |
93 total: 62 passed, 3 existing skips, 28 failed solely because
Material3 API-30 baseline snapshots are absent; no snapshots or filters
changed |
| Pushed commit rebuilt and identical expanded selector repeated | 93
total: 62 passed, 3 existing skips, 28 missing-baseline failures;
original Editor fixture 56 passed / 3 skips and Issue6250 6 passed |

Within that expanded run, the original Editor fixture is **56 passed / 3
existing skips** and Issue6250 is **6 passed**. The Material3 failures
are explicit validation limitations, not a green full-suite claim: those
snapshots exist under `android-notch-36`, not the API-30 `android`
directory.

The failing CI environment uses x86_64/CoreCLR 11.0.1/servicing SDK
11.0.101. Local ARM64 validation is not a claim that the exact CI
runtime or other platforms have passed. CI requests remain with the
coordinating maintainer/session. No manual CI or review triggers were
submitted.

Searched open and recently merged PRs for the failure, native
text-editor check, and explicit keyboard-show mechanism; #40191 is the
preceding focusability change, not a duplicate repair. #40169 changes
ContentView handling, not this focus path.

#### Exact commands and results

Run from the repository root using the local SDK/runtime and owned
emulator described above. Absolute paths below identify retained
diagnostic results; none of those diagnostic files is part of the PR.

**Passed: 0 warnings, 0 errors.**

```bash
dotnet build Microsoft.Maui.BuildTasks.slnf -c Debug -p:IncludeAndroidTargetFrameworks=true -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -v:q
```

**Passed, including the post-push build: 0 warnings, 0 errors.**

```bash
dotnet build src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj -c Debug -f net11.0-android -p:RuntimeIdentifier=android-arm64 -p:EmbedAssembliesIntoApk=true -p:UseMonoRuntime=false -p:IncludeAndroidTargetFrameworks=true -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -v:q
```

**Passed, including the post-push build: 0 warnings, 0 errors. The
external targets file changes only the task-owned Appium endpoint.**

```bash
dotnet build src/Controls/tests/TestCases.Android.Tests/Controls.TestCases.Android.Tests.csproj -c Debug -p:IncludeAndroidTargetFrameworks=true -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -p:CustomAfterMicrosoftCommonTargets=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/private-appium.targets -v:q
```

**Passed (exit 0); only these three changed C# files were included.**

```bash
dotnet format Microsoft.Maui.sln --no-restore --exclude Templates/src --exclude-diagnostics CA1822 --include src/Core/src/Platform/Android/TextViewExtensions.cs src/Controls/tests/TestCases.HostApp/Issues/Issue6250.cs src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue6250.cs --verbosity quiet
```

**Expected red with only the production guard removed: 4 failed / 4
passed / 0 skipped.**

```bash
DEVICE_UDID=emulator-5576 ANDROID_SERIAL=emulator-5576 PLATFORM_VERSION=11 DEVICE_SKIN='Nexus 5X' APPIUM_LOG_FILE=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-reverted-appium.log dotnet vstest artifacts/bin/Controls.TestCases.Android.Tests/Debug/net11.0/Controls.TestCases.Android.Tests.dll '--TestCaseFilter:FullyQualifiedName~VerifyEditorSelectionLengthWhenIsReadOnlyTrue|FullyQualifiedName~VerifyEditorCursorPositionWhenIsReadOnlyTrue|FullyQualifiedName~Microsoft.Maui.TestCases.Tests.Issues.Issue6250' '--logger:trx;LogFileName=final-reverted.trx' --ResultsDirectory:/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-reverted
```

**Guard restored: 8 passed / 0 failed / 0 skipped, including editable
programmatic-focus positive controls.**

```bash
DEVICE_UDID=emulator-5576 ANDROID_SERIAL=emulator-5576 PLATFORM_VERSION=11 DEVICE_SKIN='Nexus 5X' APPIUM_LOG_FILE=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-restored-appium.log dotnet vstest artifacts/bin/Controls.TestCases.Android.Tests/Debug/net11.0/Controls.TestCases.Android.Tests.dll '--TestCaseFilter:FullyQualifiedName~VerifyEditorSelectionLengthWhenIsReadOnlyTrue|FullyQualifiedName~VerifyEditorCursorPositionWhenIsReadOnlyTrue|FullyQualifiedName~Microsoft.Maui.TestCases.Tests.Issues.Issue6250' '--logger:trx;LogFileName=final-restored.trx' --ResultsDirectory:/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-restored
```

**Post-push full selector on a401a45:
exit 1, 62 passed / 28 failed / 3 existing skips / 93 total. Every
failure is a missing API-30 Material3 baseline; none is silently
excluded.**

```bash
DEVICE_UDID=emulator-5576 ANDROID_SERIAL=emulator-5576 PLATFORM_VERSION=11 DEVICE_SKIN='Nexus 5X' APPIUM_LOG_FILE=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/postpush-appium.log dotnet vstest artifacts/bin/Controls.TestCases.Android.Tests/Debug/net11.0/Controls.TestCases.Android.Tests.dll '--TestCaseFilter:FullyQualifiedName~EditorFeatureTests|FullyQualifiedName~Microsoft.Maui.TestCases.Tests.Issues.Issue6250' '--logger:trx;LogFileName=postpush.trx' --ResultsDirectory:/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/postpush
```

### 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. -->

Relates to #40116 and #40191. Repairs the independent Editor timeout
observed in the validation of #40248; it does not change Issue7556 or
attribute this failure to that PR's implementation.

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Vignesh-SF3580 pushed a commit to Vignesh-SF3580/maui that referenced this pull request Nov 17, 2026
… content (dotnet#40169)

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

- [ ] 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.

### Issue Description

On Android 16, switching between Entries with different keyboard types
can briefly display the previous keyboard layout before showing the
correct one, causing visible flickering. In the reproduction, each Entry
is dynamically added to a ContentView and replaced with a Label when
another cell is selected.

### Root Cause

RemoveAllViews() detached the focused native EditText without explicitly
clearing its focus. Removing a view is not the same as completing a
focus transition.

Android updates the keyboard through its input-method system
asynchronously. If the outgoing text field is still considered the
active input target, the keyboard can temporarily retain its
configuration while Android processes detachment, transfers focus, and
establishes the incoming Entry’s input connection.


### Description of Change

- Clear native focus from the outgoing ContentView content before
calling RemoveAllViews() on Android.
- Previously, removing content containing a focused Entry could leave
stale input-method state. When switching between Entries with different
keyboard types, the previous keyboard layout could briefly appear before
the correct layout.
- Explicitly clearing focus before removing the native view ensures that
the outgoing Entry relinquishes focus before the next Entry is attached
and focused.


### Issues Fixed
Fixes dotnet#38799

### Tested the behaviour in the following platforms
- [x] Android
- [ ] Windows
- [ ] iOS
- [ ] Mac

### Output Screenshot
Before Issue Fix | After Issue Fix |
|----------|----------|
|<video width="300" height="600" alt="Before Fix"
src="https://github.com/user-attachments/assets/62b49b56-86e3-48e8-9ae1-19e92106f5b0">|<video
width="100" height="100" alt="After Fix"
src="https://github.com/user-attachments/assets/55caabe9-2021-43c0-9407-31bbad08db4c">|

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
<!-- 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).

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.

This is an explicitly coordinated release-candidate repair for #40116,
targeting the designated `candidate/11.0.1xx-sr2` branch.

### Description of Change

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

Only post the explicit soft-keyboard request from
`TextViewExtensions.Focus` when Android's native `OnCheckIsTextEditor()`
returns true, while preserving the existing `ShowSoftInputOnFocus` check
and normal focus request.

**Root cause:** #40191 intentionally keeps read-only inputs focusable
and hides an existing keyboard in the native focus-change handler.
However, the shared programmatic-focus callback subsequently posts
`ShowSoftInput` even when the native input has `KeyListener = null`,
`InputType = 0`, and `OnCheckIsTextEditor() == false`. This reopens the
keyboard. In the unchanged
`VerifyEditorSelectionLengthWhenIsReadOnlyTrue` test, the sample's
Update Cursor Selection button programmatically focuses the read-only
Editor; the keyboard then obscures `SelectionLengthEntry`, causing the
timeout at line 480.

Native tracing on API 30 confirmed the Editor is genuinely read-only and
remains focusable/focused while the IME changes from hidden to visible.
A diagnostic-only control removing the explicit keyboard-show trigger
clears the unchanged test. The fix does not revert read-only
focusability or alter cursor/selection mapping. No timeouts, retry
budgets, filters, or screenshot tolerances are changed; existing
assertions are retained and focus assertions are added.

Extend the existing Issue6250 page/tests rather than adding a fixture:
exercise touch and programmatic focus for read-only Entry, Editor, and
SearchBar. Each case first proves an editable Entry shows the keyboard;
the programmatic cases use `Focus()` for that positive control too. All
cases assert that the intended read-only control actually receives focus
and the keyboard disappears. The original Editor feature tests remain
unchanged.

**Local causal validation:** Android API 30, Nexus 5X, 1080x1920, 420
dpi, ARM64, CoreCLR 11.0.0, SDK 11.0.100.

| Phase | Result |
| --- | --- |
| Unchanged original read-only Editor pair | Selection-length case times
out at the same line as CI; cursor-position case passes |
| Diagnostic trigger-removed control | Original pair: 2 passed |
| Fix applied | Original pair plus six focus cases: 8 passed |
| Only production guard reverted, final test bodies retained | 4 failed
/ 4 passed: original selection timeout and all three read-only
programmatic cases fail |
| Guard restored, no diagnostic app instrumentation | Same eight cases:
8 passed |
| Expanded selector including both Editor fixture names and Issue6250 |
93 total: 62 passed, 3 existing skips, 28 failed solely because
Material3 API-30 baseline snapshots are absent; no snapshots or filters
changed |
| Pushed commit rebuilt and identical expanded selector repeated | 93
total: 62 passed, 3 existing skips, 28 missing-baseline failures;
original Editor fixture 56 passed / 3 skips and Issue6250 6 passed |

Within that expanded run, the original Editor fixture is **56 passed / 3
existing skips** and Issue6250 is **6 passed**. The Material3 failures
are explicit validation limitations, not a green full-suite claim: those
snapshots exist under `android-notch-36`, not the API-30 `android`
directory.

The failing CI environment uses x86_64/CoreCLR 11.0.1/servicing SDK
11.0.101. Local ARM64 validation is not a claim that the exact CI
runtime or other platforms have passed. CI requests remain with the
coordinating maintainer/session. No manual CI or review triggers were
submitted.

Searched open and recently merged PRs for the failure, native
text-editor check, and explicit keyboard-show mechanism; #40191 is the
preceding focusability change, not a duplicate repair. #40169 changes
ContentView handling, not this focus path.

#### Exact commands and results

Run from the repository root using the local SDK/runtime and owned
emulator described above. Absolute paths below identify retained
diagnostic results; none of those diagnostic files is part of the PR.

**Passed: 0 warnings, 0 errors.**

```bash
dotnet build Microsoft.Maui.BuildTasks.slnf -c Debug -p:IncludeAndroidTargetFrameworks=true -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -v:q
```

**Passed, including the post-push build: 0 warnings, 0 errors.**

```bash
dotnet build src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj -c Debug -f net11.0-android -p:RuntimeIdentifier=android-arm64 -p:EmbedAssembliesIntoApk=true -p:UseMonoRuntime=false -p:IncludeAndroidTargetFrameworks=true -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -v:q
```

**Passed, including the post-push build: 0 warnings, 0 errors. The
external targets file changes only the task-owned Appium endpoint.**

```bash
dotnet build src/Controls/tests/TestCases.Android.Tests/Controls.TestCases.Android.Tests.csproj -c Debug -p:IncludeAndroidTargetFrameworks=true -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -p:CustomAfterMicrosoftCommonTargets=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/private-appium.targets -v:q
```

**Passed (exit 0); only these three changed C# files were included.**

```bash
dotnet format Microsoft.Maui.sln --no-restore --exclude Templates/src --exclude-diagnostics CA1822 --include src/Core/src/Platform/Android/TextViewExtensions.cs src/Controls/tests/TestCases.HostApp/Issues/Issue6250.cs src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue6250.cs --verbosity quiet
```

**Expected red with only the production guard removed: 4 failed / 4
passed / 0 skipped.**

```bash
DEVICE_UDID=emulator-5576 ANDROID_SERIAL=emulator-5576 PLATFORM_VERSION=11 DEVICE_SKIN='Nexus 5X' APPIUM_LOG_FILE=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-reverted-appium.log dotnet vstest artifacts/bin/Controls.TestCases.Android.Tests/Debug/net11.0/Controls.TestCases.Android.Tests.dll '--TestCaseFilter:FullyQualifiedName~VerifyEditorSelectionLengthWhenIsReadOnlyTrue|FullyQualifiedName~VerifyEditorCursorPositionWhenIsReadOnlyTrue|FullyQualifiedName~Microsoft.Maui.TestCases.Tests.Issues.Issue6250' '--logger:trx;LogFileName=final-reverted.trx' --ResultsDirectory:/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-reverted
```

**Guard restored: 8 passed / 0 failed / 0 skipped, including editable
programmatic-focus positive controls.**

```bash
DEVICE_UDID=emulator-5576 ANDROID_SERIAL=emulator-5576 PLATFORM_VERSION=11 DEVICE_SKIN='Nexus 5X' APPIUM_LOG_FILE=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-restored-appium.log dotnet vstest artifacts/bin/Controls.TestCases.Android.Tests/Debug/net11.0/Controls.TestCases.Android.Tests.dll '--TestCaseFilter:FullyQualifiedName~VerifyEditorSelectionLengthWhenIsReadOnlyTrue|FullyQualifiedName~VerifyEditorCursorPositionWhenIsReadOnlyTrue|FullyQualifiedName~Microsoft.Maui.TestCases.Tests.Issues.Issue6250' '--logger:trx;LogFileName=final-restored.trx' --ResultsDirectory:/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-restored
```

**Post-push full selector on a401a45:
exit 1, 62 passed / 28 failed / 3 existing skips / 93 total. Every
failure is a missing API-30 Material3 baseline; none is silently
excluded.**

```bash
DEVICE_UDID=emulator-5576 ANDROID_SERIAL=emulator-5576 PLATFORM_VERSION=11 DEVICE_SKIN='Nexus 5X' APPIUM_LOG_FILE=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/postpush-appium.log dotnet vstest artifacts/bin/Controls.TestCases.Android.Tests/Debug/net11.0/Controls.TestCases.Android.Tests.dll '--TestCaseFilter:FullyQualifiedName~EditorFeatureTests|FullyQualifiedName~Microsoft.Maui.TestCases.Tests.Issues.Issue6250' '--logger:trx;LogFileName=postpush.trx' --ResultsDirectory:/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/postpush
```

### 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. -->

Relates to #40116 and #40191. Repairs the independent Editor timeout
observed in the validation of #40248; it does not change Issue7556 or
attribute this failure to that PR's implementation.

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
marcelomoresco pushed a commit to marcelomoresco/dotnet-maui that referenced this pull request Nov 18, 2026
… content (dotnet#40169)

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

- [ ] 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.

### Issue Description

On Android 16, switching between Entries with different keyboard types
can briefly display the previous keyboard layout before showing the
correct one, causing visible flickering. In the reproduction, each Entry
is dynamically added to a ContentView and replaced with a Label when
another cell is selected.

### Root Cause

RemoveAllViews() detached the focused native EditText without explicitly
clearing its focus. Removing a view is not the same as completing a
focus transition.

Android updates the keyboard through its input-method system
asynchronously. If the outgoing text field is still considered the
active input target, the keyboard can temporarily retain its
configuration while Android processes detachment, transfers focus, and
establishes the incoming Entry’s input connection.


### Description of Change

- Clear native focus from the outgoing ContentView content before
calling RemoveAllViews() on Android.
- Previously, removing content containing a focused Entry could leave
stale input-method state. When switching between Entries with different
keyboard types, the previous keyboard layout could briefly appear before
the correct layout.
- Explicitly clearing focus before removing the native view ensures that
the outgoing Entry relinquishes focus before the next Entry is attached
and focused.


### Issues Fixed
Fixes dotnet#38799

### Tested the behaviour in the following platforms
- [x] Android
- [ ] Windows
- [ ] iOS
- [ ] Mac

### Output Screenshot
Before Issue Fix | After Issue Fix |
|----------|----------|
|<video width="300" height="600" alt="Before Fix"
src="https://github.com/user-attachments/assets/62b49b56-86e3-48e8-9ae1-19e92106f5b0">|<video
width="100" height="100" alt="After Fix"
src="https://github.com/user-attachments/assets/55caabe9-2021-43c0-9407-31bbad08db4c">|

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
<!-- 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).

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.

This is an explicitly coordinated release-candidate repair for #40116,
targeting the designated `candidate/11.0.1xx-sr2` branch.

### Description of Change

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

Only post the explicit soft-keyboard request from
`TextViewExtensions.Focus` when Android's native `OnCheckIsTextEditor()`
returns true, while preserving the existing `ShowSoftInputOnFocus` check
and normal focus request.

**Root cause:** #40191 intentionally keeps read-only inputs focusable
and hides an existing keyboard in the native focus-change handler.
However, the shared programmatic-focus callback subsequently posts
`ShowSoftInput` even when the native input has `KeyListener = null`,
`InputType = 0`, and `OnCheckIsTextEditor() == false`. This reopens the
keyboard. In the unchanged
`VerifyEditorSelectionLengthWhenIsReadOnlyTrue` test, the sample's
Update Cursor Selection button programmatically focuses the read-only
Editor; the keyboard then obscures `SelectionLengthEntry`, causing the
timeout at line 480.

Native tracing on API 30 confirmed the Editor is genuinely read-only and
remains focusable/focused while the IME changes from hidden to visible.
A diagnostic-only control removing the explicit keyboard-show trigger
clears the unchanged test. The fix does not revert read-only
focusability or alter cursor/selection mapping. No timeouts, retry
budgets, filters, or screenshot tolerances are changed; existing
assertions are retained and focus assertions are added.

Extend the existing Issue6250 page/tests rather than adding a fixture:
exercise touch and programmatic focus for read-only Entry, Editor, and
SearchBar. Each case first proves an editable Entry shows the keyboard;
the programmatic cases use `Focus()` for that positive control too. All
cases assert that the intended read-only control actually receives focus
and the keyboard disappears. The original Editor feature tests remain
unchanged.

**Local causal validation:** Android API 30, Nexus 5X, 1080x1920, 420
dpi, ARM64, CoreCLR 11.0.0, SDK 11.0.100.

| Phase | Result |
| --- | --- |
| Unchanged original read-only Editor pair | Selection-length case times
out at the same line as CI; cursor-position case passes |
| Diagnostic trigger-removed control | Original pair: 2 passed |
| Fix applied | Original pair plus six focus cases: 8 passed |
| Only production guard reverted, final test bodies retained | 4 failed
/ 4 passed: original selection timeout and all three read-only
programmatic cases fail |
| Guard restored, no diagnostic app instrumentation | Same eight cases:
8 passed |
| Expanded selector including both Editor fixture names and Issue6250 |
93 total: 62 passed, 3 existing skips, 28 failed solely because
Material3 API-30 baseline snapshots are absent; no snapshots or filters
changed |
| Pushed commit rebuilt and identical expanded selector repeated | 93
total: 62 passed, 3 existing skips, 28 missing-baseline failures;
original Editor fixture 56 passed / 3 skips and Issue6250 6 passed |

Within that expanded run, the original Editor fixture is **56 passed / 3
existing skips** and Issue6250 is **6 passed**. The Material3 failures
are explicit validation limitations, not a green full-suite claim: those
snapshots exist under `android-notch-36`, not the API-30 `android`
directory.

The failing CI environment uses x86_64/CoreCLR 11.0.1/servicing SDK
11.0.101. Local ARM64 validation is not a claim that the exact CI
runtime or other platforms have passed. CI requests remain with the
coordinating maintainer/session. No manual CI or review triggers were
submitted.

Searched open and recently merged PRs for the failure, native
text-editor check, and explicit keyboard-show mechanism; #40191 is the
preceding focusability change, not a duplicate repair. #40169 changes
ContentView handling, not this focus path.

#### Exact commands and results

Run from the repository root using the local SDK/runtime and owned
emulator described above. Absolute paths below identify retained
diagnostic results; none of those diagnostic files is part of the PR.

**Passed: 0 warnings, 0 errors.**

```bash
dotnet build Microsoft.Maui.BuildTasks.slnf -c Debug -p:IncludeAndroidTargetFrameworks=true -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -v:q
```

**Passed, including the post-push build: 0 warnings, 0 errors.**

```bash
dotnet build src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj -c Debug -f net11.0-android -p:RuntimeIdentifier=android-arm64 -p:EmbedAssembliesIntoApk=true -p:UseMonoRuntime=false -p:IncludeAndroidTargetFrameworks=true -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -v:q
```

**Passed, including the post-push build: 0 warnings, 0 errors. The
external targets file changes only the task-owned Appium endpoint.**

```bash
dotnet build src/Controls/tests/TestCases.Android.Tests/Controls.TestCases.Android.Tests.csproj -c Debug -p:IncludeAndroidTargetFrameworks=true -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -p:CustomAfterMicrosoftCommonTargets=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/private-appium.targets -v:q
```

**Passed (exit 0); only these three changed C# files were included.**

```bash
dotnet format Microsoft.Maui.sln --no-restore --exclude Templates/src --exclude-diagnostics CA1822 --include src/Core/src/Platform/Android/TextViewExtensions.cs src/Controls/tests/TestCases.HostApp/Issues/Issue6250.cs src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue6250.cs --verbosity quiet
```

**Expected red with only the production guard removed: 4 failed / 4
passed / 0 skipped.**

```bash
DEVICE_UDID=emulator-5576 ANDROID_SERIAL=emulator-5576 PLATFORM_VERSION=11 DEVICE_SKIN='Nexus 5X' APPIUM_LOG_FILE=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-reverted-appium.log dotnet vstest artifacts/bin/Controls.TestCases.Android.Tests/Debug/net11.0/Controls.TestCases.Android.Tests.dll '--TestCaseFilter:FullyQualifiedName~VerifyEditorSelectionLengthWhenIsReadOnlyTrue|FullyQualifiedName~VerifyEditorCursorPositionWhenIsReadOnlyTrue|FullyQualifiedName~Microsoft.Maui.TestCases.Tests.Issues.Issue6250' '--logger:trx;LogFileName=final-reverted.trx' --ResultsDirectory:/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-reverted
```

**Guard restored: 8 passed / 0 failed / 0 skipped, including editable
programmatic-focus positive controls.**

```bash
DEVICE_UDID=emulator-5576 ANDROID_SERIAL=emulator-5576 PLATFORM_VERSION=11 DEVICE_SKIN='Nexus 5X' APPIUM_LOG_FILE=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-restored-appium.log dotnet vstest artifacts/bin/Controls.TestCases.Android.Tests/Debug/net11.0/Controls.TestCases.Android.Tests.dll '--TestCaseFilter:FullyQualifiedName~VerifyEditorSelectionLengthWhenIsReadOnlyTrue|FullyQualifiedName~VerifyEditorCursorPositionWhenIsReadOnlyTrue|FullyQualifiedName~Microsoft.Maui.TestCases.Tests.Issues.Issue6250' '--logger:trx;LogFileName=final-restored.trx' --ResultsDirectory:/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-restored
```

**Post-push full selector on a401a45:
exit 1, 62 passed / 28 failed / 3 existing skips / 93 total. Every
failure is a missing API-30 Material3 baseline; none is silently
excluded.**

```bash
DEVICE_UDID=emulator-5576 ANDROID_SERIAL=emulator-5576 PLATFORM_VERSION=11 DEVICE_SKIN='Nexus 5X' APPIUM_LOG_FILE=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/postpush-appium.log dotnet vstest artifacts/bin/Controls.TestCases.Android.Tests/Debug/net11.0/Controls.TestCases.Android.Tests.dll '--TestCaseFilter:FullyQualifiedName~EditorFeatureTests|FullyQualifiedName~Microsoft.Maui.TestCases.Tests.Issues.Issue6250' '--logger:trx;LogFileName=postpush.trx' --ResultsDirectory:/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/postpush
```

### 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. -->

Relates to #40116 and #40191. Repairs the independent Editor timeout
observed in the validation of #40248; it does not change Issue7556 or
attribute this failure to that PR's implementation.

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
<!-- 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).

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.

This is an explicitly coordinated release-candidate repair for #40116,
targeting the designated `candidate/11.0.1xx-sr2` branch.

### Description of Change

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

Only post the explicit soft-keyboard request from
`TextViewExtensions.Focus` when Android's native `OnCheckIsTextEditor()`
returns true, while preserving the existing `ShowSoftInputOnFocus` check
and normal focus request.

**Root cause:** #40191 intentionally keeps read-only inputs focusable
and hides an existing keyboard in the native focus-change handler.
However, the shared programmatic-focus callback subsequently posts
`ShowSoftInput` even when the native input has `KeyListener = null`,
`InputType = 0`, and `OnCheckIsTextEditor() == false`. This reopens the
keyboard. In the unchanged
`VerifyEditorSelectionLengthWhenIsReadOnlyTrue` test, the sample's
Update Cursor Selection button programmatically focuses the read-only
Editor; the keyboard then obscures `SelectionLengthEntry`, causing the
timeout at line 480.

Native tracing on API 30 confirmed the Editor is genuinely read-only and
remains focusable/focused while the IME changes from hidden to visible.
A diagnostic-only control removing the explicit keyboard-show trigger
clears the unchanged test. The fix does not revert read-only
focusability or alter cursor/selection mapping. No timeouts, retry
budgets, filters, or screenshot tolerances are changed; existing
assertions are retained and focus assertions are added.

Extend the existing Issue6250 page/tests rather than adding a fixture:
exercise touch and programmatic focus for read-only Entry, Editor, and
SearchBar. Each case first proves an editable Entry shows the keyboard;
the programmatic cases use `Focus()` for that positive control too. All
cases assert that the intended read-only control actually receives focus
and the keyboard disappears. The original Editor feature tests remain
unchanged.

**Local causal validation:** Android API 30, Nexus 5X, 1080x1920, 420
dpi, ARM64, CoreCLR 11.0.0, SDK 11.0.100.

| Phase | Result |
| --- | --- |
| Unchanged original read-only Editor pair | Selection-length case times
out at the same line as CI; cursor-position case passes |
| Diagnostic trigger-removed control | Original pair: 2 passed |
| Fix applied | Original pair plus six focus cases: 8 passed |
| Only production guard reverted, final test bodies retained | 4 failed
/ 4 passed: original selection timeout and all three read-only
programmatic cases fail |
| Guard restored, no diagnostic app instrumentation | Same eight cases:
8 passed |
| Expanded selector including both Editor fixture names and Issue6250 |
93 total: 62 passed, 3 existing skips, 28 failed solely because
Material3 API-30 baseline snapshots are absent; no snapshots or filters
changed |
| Pushed commit rebuilt and identical expanded selector repeated | 93
total: 62 passed, 3 existing skips, 28 missing-baseline failures;
original Editor fixture 56 passed / 3 skips and Issue6250 6 passed |

Within that expanded run, the original Editor fixture is **56 passed / 3
existing skips** and Issue6250 is **6 passed**. The Material3 failures
are explicit validation limitations, not a green full-suite claim: those
snapshots exist under `android-notch-36`, not the API-30 `android`
directory.

The failing CI environment uses x86_64/CoreCLR 11.0.1/servicing SDK
11.0.101. Local ARM64 validation is not a claim that the exact CI
runtime or other platforms have passed. CI requests remain with the
coordinating maintainer/session. No manual CI or review triggers were
submitted.

Searched open and recently merged PRs for the failure, native
text-editor check, and explicit keyboard-show mechanism; #40191 is the
preceding focusability change, not a duplicate repair. #40169 changes
ContentView handling, not this focus path.

#### Exact commands and results

Run from the repository root using the local SDK/runtime and owned
emulator described above. Absolute paths below identify retained
diagnostic results; none of those diagnostic files is part of the PR.

**Passed: 0 warnings, 0 errors.**

```bash
dotnet build Microsoft.Maui.BuildTasks.slnf -c Debug -p:IncludeAndroidTargetFrameworks=true -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -v:q
```

**Passed, including the post-push build: 0 warnings, 0 errors.**

```bash
dotnet build src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj -c Debug -f net11.0-android -p:RuntimeIdentifier=android-arm64 -p:EmbedAssembliesIntoApk=true -p:UseMonoRuntime=false -p:IncludeAndroidTargetFrameworks=true -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -v:q
```

**Passed, including the post-push build: 0 warnings, 0 errors. The
external targets file changes only the task-owned Appium endpoint.**

```bash
dotnet build src/Controls/tests/TestCases.Android.Tests/Controls.TestCases.Android.Tests.csproj -c Debug -p:IncludeAndroidTargetFrameworks=true -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -p:CustomAfterMicrosoftCommonTargets=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/private-appium.targets -v:q
```

**Passed (exit 0); only these three changed C# files were included.**

```bash
dotnet format Microsoft.Maui.sln --no-restore --exclude Templates/src --exclude-diagnostics CA1822 --include src/Core/src/Platform/Android/TextViewExtensions.cs src/Controls/tests/TestCases.HostApp/Issues/Issue6250.cs src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue6250.cs --verbosity quiet
```

**Expected red with only the production guard removed: 4 failed / 4
passed / 0 skipped.**

```bash
DEVICE_UDID=emulator-5576 ANDROID_SERIAL=emulator-5576 PLATFORM_VERSION=11 DEVICE_SKIN='Nexus 5X' APPIUM_LOG_FILE=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-reverted-appium.log dotnet vstest artifacts/bin/Controls.TestCases.Android.Tests/Debug/net11.0/Controls.TestCases.Android.Tests.dll '--TestCaseFilter:FullyQualifiedName~VerifyEditorSelectionLengthWhenIsReadOnlyTrue|FullyQualifiedName~VerifyEditorCursorPositionWhenIsReadOnlyTrue|FullyQualifiedName~Microsoft.Maui.TestCases.Tests.Issues.Issue6250' '--logger:trx;LogFileName=final-reverted.trx' --ResultsDirectory:/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-reverted
```

**Guard restored: 8 passed / 0 failed / 0 skipped, including editable
programmatic-focus positive controls.**

```bash
DEVICE_UDID=emulator-5576 ANDROID_SERIAL=emulator-5576 PLATFORM_VERSION=11 DEVICE_SKIN='Nexus 5X' APPIUM_LOG_FILE=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-restored-appium.log dotnet vstest artifacts/bin/Controls.TestCases.Android.Tests/Debug/net11.0/Controls.TestCases.Android.Tests.dll '--TestCaseFilter:FullyQualifiedName~VerifyEditorSelectionLengthWhenIsReadOnlyTrue|FullyQualifiedName~VerifyEditorCursorPositionWhenIsReadOnlyTrue|FullyQualifiedName~Microsoft.Maui.TestCases.Tests.Issues.Issue6250' '--logger:trx;LogFileName=final-restored.trx' --ResultsDirectory:/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-restored
```

**Post-push full selector on a401a45:
exit 1, 62 passed / 28 failed / 3 existing skips / 93 total. Every
failure is a missing API-30 Material3 baseline; none is silently
excluded.**

```bash
DEVICE_UDID=emulator-5576 ANDROID_SERIAL=emulator-5576 PLATFORM_VERSION=11 DEVICE_SKIN='Nexus 5X' APPIUM_LOG_FILE=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/postpush-appium.log dotnet vstest artifacts/bin/Controls.TestCases.Android.Tests/Debug/net11.0/Controls.TestCases.Android.Tests.dll '--TestCaseFilter:FullyQualifiedName~EditorFeatureTests|FullyQualifiedName~Microsoft.Maui.TestCases.Tests.Issues.Issue6250' '--logger:trx;LogFileName=postpush.trx' --ResultsDirectory:/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/postpush
```

### 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. -->

Relates to #40116 and #40191. Repairs the independent Editor timeout
observed in the validation of #40248; it does not change Issue7556 or
attribute this failure to that PR's implementation.

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 19, 2026
<!-- 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).

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.

This is an explicitly coordinated release-candidate repair for #40116,
targeting the designated `candidate/11.0.1xx-sr2` branch.

### Description of Change

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

Only post the explicit soft-keyboard request from
`TextViewExtensions.Focus` when Android's native `OnCheckIsTextEditor()`
returns true, while preserving the existing `ShowSoftInputOnFocus` check
and normal focus request.

**Root cause:** #40191 intentionally keeps read-only inputs focusable
and hides an existing keyboard in the native focus-change handler.
However, the shared programmatic-focus callback subsequently posts
`ShowSoftInput` even when the native input has `KeyListener = null`,
`InputType = 0`, and `OnCheckIsTextEditor() == false`. This reopens the
keyboard. In the unchanged
`VerifyEditorSelectionLengthWhenIsReadOnlyTrue` test, the sample's
Update Cursor Selection button programmatically focuses the read-only
Editor; the keyboard then obscures `SelectionLengthEntry`, causing the
timeout at line 480.

Native tracing on API 30 confirmed the Editor is genuinely read-only and
remains focusable/focused while the IME changes from hidden to visible.
A diagnostic-only control removing the explicit keyboard-show trigger
clears the unchanged test. The fix does not revert read-only
focusability or alter cursor/selection mapping. No timeouts, retry
budgets, filters, or screenshot tolerances are changed; existing
assertions are retained and focus assertions are added.

Extend the existing Issue6250 page/tests rather than adding a fixture:
exercise touch and programmatic focus for read-only Entry, Editor, and
SearchBar. Each case first proves an editable Entry shows the keyboard;
the programmatic cases use `Focus()` for that positive control too. All
cases assert that the intended read-only control actually receives focus
and the keyboard disappears. The original Editor feature tests remain
unchanged.

**Local causal validation:** Android API 30, Nexus 5X, 1080x1920, 420
dpi, ARM64, CoreCLR 11.0.0, SDK 11.0.100.

| Phase | Result |
| --- | --- |
| Unchanged original read-only Editor pair | Selection-length case times
out at the same line as CI; cursor-position case passes |
| Diagnostic trigger-removed control | Original pair: 2 passed |
| Fix applied | Original pair plus six focus cases: 8 passed |
| Only production guard reverted, final test bodies retained | 4 failed
/ 4 passed: original selection timeout and all three read-only
programmatic cases fail |
| Guard restored, no diagnostic app instrumentation | Same eight cases:
8 passed |
| Expanded selector including both Editor fixture names and Issue6250 |
93 total: 62 passed, 3 existing skips, 28 failed solely because
Material3 API-30 baseline snapshots are absent; no snapshots or filters
changed |
| Pushed commit rebuilt and identical expanded selector repeated | 93
total: 62 passed, 3 existing skips, 28 missing-baseline failures;
original Editor fixture 56 passed / 3 skips and Issue6250 6 passed |

Within that expanded run, the original Editor fixture is **56 passed / 3
existing skips** and Issue6250 is **6 passed**. The Material3 failures
are explicit validation limitations, not a green full-suite claim: those
snapshots exist under `android-notch-36`, not the API-30 `android`
directory.

The failing CI environment uses x86_64/CoreCLR 11.0.1/servicing SDK
11.0.101. Local ARM64 validation is not a claim that the exact CI
runtime or other platforms have passed. CI requests remain with the
coordinating maintainer/session. No manual CI or review triggers were
submitted.

Searched open and recently merged PRs for the failure, native
text-editor check, and explicit keyboard-show mechanism; #40191 is the
preceding focusability change, not a duplicate repair. #40169 changes
ContentView handling, not this focus path.

#### Exact commands and results

Run from the repository root using the local SDK/runtime and owned
emulator described above. Absolute paths below identify retained
diagnostic results; none of those diagnostic files is part of the PR.

**Passed: 0 warnings, 0 errors.**

```bash
dotnet build Microsoft.Maui.BuildTasks.slnf -c Debug -p:IncludeAndroidTargetFrameworks=true -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -v:q
```

**Passed, including the post-push build: 0 warnings, 0 errors.**

```bash
dotnet build src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj -c Debug -f net11.0-android -p:RuntimeIdentifier=android-arm64 -p:EmbedAssembliesIntoApk=true -p:UseMonoRuntime=false -p:IncludeAndroidTargetFrameworks=true -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -v:q
```

**Passed, including the post-push build: 0 warnings, 0 errors. The
external targets file changes only the task-owned Appium endpoint.**

```bash
dotnet build src/Controls/tests/TestCases.Android.Tests/Controls.TestCases.Android.Tests.csproj -c Debug -p:IncludeAndroidTargetFrameworks=true -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -p:CustomAfterMicrosoftCommonTargets=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/private-appium.targets -v:q
```

**Passed (exit 0); only these three changed C# files were included.**

```bash
dotnet format Microsoft.Maui.sln --no-restore --exclude Templates/src --exclude-diagnostics CA1822 --include src/Core/src/Platform/Android/TextViewExtensions.cs src/Controls/tests/TestCases.HostApp/Issues/Issue6250.cs src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue6250.cs --verbosity quiet
```

**Expected red with only the production guard removed: 4 failed / 4
passed / 0 skipped.**

```bash
DEVICE_UDID=emulator-5576 ANDROID_SERIAL=emulator-5576 PLATFORM_VERSION=11 DEVICE_SKIN='Nexus 5X' APPIUM_LOG_FILE=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-reverted-appium.log dotnet vstest artifacts/bin/Controls.TestCases.Android.Tests/Debug/net11.0/Controls.TestCases.Android.Tests.dll '--TestCaseFilter:FullyQualifiedName~VerifyEditorSelectionLengthWhenIsReadOnlyTrue|FullyQualifiedName~VerifyEditorCursorPositionWhenIsReadOnlyTrue|FullyQualifiedName~Microsoft.Maui.TestCases.Tests.Issues.Issue6250' '--logger:trx;LogFileName=final-reverted.trx' --ResultsDirectory:/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-reverted
```

**Guard restored: 8 passed / 0 failed / 0 skipped, including editable
programmatic-focus positive controls.**

```bash
DEVICE_UDID=emulator-5576 ANDROID_SERIAL=emulator-5576 PLATFORM_VERSION=11 DEVICE_SKIN='Nexus 5X' APPIUM_LOG_FILE=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-restored-appium.log dotnet vstest artifacts/bin/Controls.TestCases.Android.Tests/Debug/net11.0/Controls.TestCases.Android.Tests.dll '--TestCaseFilter:FullyQualifiedName~VerifyEditorSelectionLengthWhenIsReadOnlyTrue|FullyQualifiedName~VerifyEditorCursorPositionWhenIsReadOnlyTrue|FullyQualifiedName~Microsoft.Maui.TestCases.Tests.Issues.Issue6250' '--logger:trx;LogFileName=final-restored.trx' --ResultsDirectory:/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-restored
```

**Post-push full selector on a401a45:
exit 1, 62 passed / 28 failed / 3 existing skips / 93 total. Every
failure is a missing API-30 Material3 baseline; none is silently
excluded.**

```bash
DEVICE_UDID=emulator-5576 ANDROID_SERIAL=emulator-5576 PLATFORM_VERSION=11 DEVICE_SKIN='Nexus 5X' APPIUM_LOG_FILE=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/postpush-appium.log dotnet vstest artifacts/bin/Controls.TestCases.Android.Tests/Debug/net11.0/Controls.TestCases.Android.Tests.dll '--TestCaseFilter:FullyQualifiedName~EditorFeatureTests|FullyQualifiedName~Microsoft.Maui.TestCases.Tests.Issues.Issue6250' '--logger:trx;LogFileName=postpush.trx' --ResultsDirectory:/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/postpush
```

### 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. -->

Relates to #40116 and #40191. Repairs the independent Editor timeout
observed in the validation of #40248; it does not change Issue7556 or
attribute this failure to that PR's implementation.

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 22, 2026
<!-- 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).

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.

This is an explicitly coordinated release-candidate repair for #40116,
targeting the designated `candidate/11.0.1xx-sr2` branch.

### Description of Change

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

Only post the explicit soft-keyboard request from
`TextViewExtensions.Focus` when Android's native `OnCheckIsTextEditor()`
returns true, while preserving the existing `ShowSoftInputOnFocus` check
and normal focus request.

**Root cause:** #40191 intentionally keeps read-only inputs focusable
and hides an existing keyboard in the native focus-change handler.
However, the shared programmatic-focus callback subsequently posts
`ShowSoftInput` even when the native input has `KeyListener = null`,
`InputType = 0`, and `OnCheckIsTextEditor() == false`. This reopens the
keyboard. In the unchanged
`VerifyEditorSelectionLengthWhenIsReadOnlyTrue` test, the sample's
Update Cursor Selection button programmatically focuses the read-only
Editor; the keyboard then obscures `SelectionLengthEntry`, causing the
timeout at line 480.

Native tracing on API 30 confirmed the Editor is genuinely read-only and
remains focusable/focused while the IME changes from hidden to visible.
A diagnostic-only control removing the explicit keyboard-show trigger
clears the unchanged test. The fix does not revert read-only
focusability or alter cursor/selection mapping. No timeouts, retry
budgets, filters, or screenshot tolerances are changed; existing
assertions are retained and focus assertions are added.

Extend the existing Issue6250 page/tests rather than adding a fixture:
exercise touch and programmatic focus for read-only Entry, Editor, and
SearchBar. Each case first proves an editable Entry shows the keyboard;
the programmatic cases use `Focus()` for that positive control too. All
cases assert that the intended read-only control actually receives focus
and the keyboard disappears. The original Editor feature tests remain
unchanged.

**Local causal validation:** Android API 30, Nexus 5X, 1080x1920, 420
dpi, ARM64, CoreCLR 11.0.0, SDK 11.0.100.

| Phase | Result |
| --- | --- |
| Unchanged original read-only Editor pair | Selection-length case times
out at the same line as CI; cursor-position case passes |
| Diagnostic trigger-removed control | Original pair: 2 passed |
| Fix applied | Original pair plus six focus cases: 8 passed |
| Only production guard reverted, final test bodies retained | 4 failed
/ 4 passed: original selection timeout and all three read-only
programmatic cases fail |
| Guard restored, no diagnostic app instrumentation | Same eight cases:
8 passed |
| Expanded selector including both Editor fixture names and Issue6250 |
93 total: 62 passed, 3 existing skips, 28 failed solely because
Material3 API-30 baseline snapshots are absent; no snapshots or filters
changed |
| Pushed commit rebuilt and identical expanded selector repeated | 93
total: 62 passed, 3 existing skips, 28 missing-baseline failures;
original Editor fixture 56 passed / 3 skips and Issue6250 6 passed |

Within that expanded run, the original Editor fixture is **56 passed / 3
existing skips** and Issue6250 is **6 passed**. The Material3 failures
are explicit validation limitations, not a green full-suite claim: those
snapshots exist under `android-notch-36`, not the API-30 `android`
directory.

The failing CI environment uses x86_64/CoreCLR 11.0.1/servicing SDK
11.0.101. Local ARM64 validation is not a claim that the exact CI
runtime or other platforms have passed. CI requests remain with the
coordinating maintainer/session. No manual CI or review triggers were
submitted.

Searched open and recently merged PRs for the failure, native
text-editor check, and explicit keyboard-show mechanism; #40191 is the
preceding focusability change, not a duplicate repair. #40169 changes
ContentView handling, not this focus path.

#### Exact commands and results

Run from the repository root using the local SDK/runtime and owned
emulator described above. Absolute paths below identify retained
diagnostic results; none of those diagnostic files is part of the PR.

**Passed: 0 warnings, 0 errors.**

```bash
dotnet build Microsoft.Maui.BuildTasks.slnf -c Debug -p:IncludeAndroidTargetFrameworks=true -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -v:q
```

**Passed, including the post-push build: 0 warnings, 0 errors.**

```bash
dotnet build src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj -c Debug -f net11.0-android -p:RuntimeIdentifier=android-arm64 -p:EmbedAssembliesIntoApk=true -p:UseMonoRuntime=false -p:IncludeAndroidTargetFrameworks=true -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -v:q
```

**Passed, including the post-push build: 0 warnings, 0 errors. The
external targets file changes only the task-owned Appium endpoint.**

```bash
dotnet build src/Controls/tests/TestCases.Android.Tests/Controls.TestCases.Android.Tests.csproj -c Debug -p:IncludeAndroidTargetFrameworks=true -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -p:CustomAfterMicrosoftCommonTargets=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/private-appium.targets -v:q
```

**Passed (exit 0); only these three changed C# files were included.**

```bash
dotnet format Microsoft.Maui.sln --no-restore --exclude Templates/src --exclude-diagnostics CA1822 --include src/Core/src/Platform/Android/TextViewExtensions.cs src/Controls/tests/TestCases.HostApp/Issues/Issue6250.cs src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue6250.cs --verbosity quiet
```

**Expected red with only the production guard removed: 4 failed / 4
passed / 0 skipped.**

```bash
DEVICE_UDID=emulator-5576 ANDROID_SERIAL=emulator-5576 PLATFORM_VERSION=11 DEVICE_SKIN='Nexus 5X' APPIUM_LOG_FILE=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-reverted-appium.log dotnet vstest artifacts/bin/Controls.TestCases.Android.Tests/Debug/net11.0/Controls.TestCases.Android.Tests.dll '--TestCaseFilter:FullyQualifiedName~VerifyEditorSelectionLengthWhenIsReadOnlyTrue|FullyQualifiedName~VerifyEditorCursorPositionWhenIsReadOnlyTrue|FullyQualifiedName~Microsoft.Maui.TestCases.Tests.Issues.Issue6250' '--logger:trx;LogFileName=final-reverted.trx' --ResultsDirectory:/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-reverted
```

**Guard restored: 8 passed / 0 failed / 0 skipped, including editable
programmatic-focus positive controls.**

```bash
DEVICE_UDID=emulator-5576 ANDROID_SERIAL=emulator-5576 PLATFORM_VERSION=11 DEVICE_SKIN='Nexus 5X' APPIUM_LOG_FILE=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-restored-appium.log dotnet vstest artifacts/bin/Controls.TestCases.Android.Tests/Debug/net11.0/Controls.TestCases.Android.Tests.dll '--TestCaseFilter:FullyQualifiedName~VerifyEditorSelectionLengthWhenIsReadOnlyTrue|FullyQualifiedName~VerifyEditorCursorPositionWhenIsReadOnlyTrue|FullyQualifiedName~Microsoft.Maui.TestCases.Tests.Issues.Issue6250' '--logger:trx;LogFileName=final-restored.trx' --ResultsDirectory:/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-restored
```

**Post-push full selector on a401a45:
exit 1, 62 passed / 28 failed / 3 existing skips / 93 total. Every
failure is a missing API-30 Material3 baseline; none is silently
excluded.**

```bash
DEVICE_UDID=emulator-5576 ANDROID_SERIAL=emulator-5576 PLATFORM_VERSION=11 DEVICE_SKIN='Nexus 5X' APPIUM_LOG_FILE=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/postpush-appium.log dotnet vstest artifacts/bin/Controls.TestCases.Android.Tests/Debug/net11.0/Controls.TestCases.Android.Tests.dll '--TestCaseFilter:FullyQualifiedName~EditorFeatureTests|FullyQualifiedName~Microsoft.Maui.TestCases.Tests.Issues.Issue6250' '--logger:trx;LogFileName=postpush.trx' --ResultsDirectory:/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/postpush
```

### 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. -->

Relates to #40116 and #40191. Repairs the independent Editor timeout
observed in the validation of #40248; it does not change Issue7556 or
attribute this failure to that PR's implementation.

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 23, 2026
<!-- 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).

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.

This is an explicitly coordinated release-candidate repair for #40116,
targeting the designated `candidate/11.0.1xx-sr2` branch.

### Description of Change

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

Only post the explicit soft-keyboard request from
`TextViewExtensions.Focus` when Android's native `OnCheckIsTextEditor()`
returns true, while preserving the existing `ShowSoftInputOnFocus` check
and normal focus request.

**Root cause:** #40191 intentionally keeps read-only inputs focusable
and hides an existing keyboard in the native focus-change handler.
However, the shared programmatic-focus callback subsequently posts
`ShowSoftInput` even when the native input has `KeyListener = null`,
`InputType = 0`, and `OnCheckIsTextEditor() == false`. This reopens the
keyboard. In the unchanged
`VerifyEditorSelectionLengthWhenIsReadOnlyTrue` test, the sample's
Update Cursor Selection button programmatically focuses the read-only
Editor; the keyboard then obscures `SelectionLengthEntry`, causing the
timeout at line 480.

Native tracing on API 30 confirmed the Editor is genuinely read-only and
remains focusable/focused while the IME changes from hidden to visible.
A diagnostic-only control removing the explicit keyboard-show trigger
clears the unchanged test. The fix does not revert read-only
focusability or alter cursor/selection mapping. No timeouts, retry
budgets, filters, or screenshot tolerances are changed; existing
assertions are retained and focus assertions are added.

Extend the existing Issue6250 page/tests rather than adding a fixture:
exercise touch and programmatic focus for read-only Entry, Editor, and
SearchBar. Each case first proves an editable Entry shows the keyboard;
the programmatic cases use `Focus()` for that positive control too. All
cases assert that the intended read-only control actually receives focus
and the keyboard disappears. The original Editor feature tests remain
unchanged.

**Local causal validation:** Android API 30, Nexus 5X, 1080x1920, 420
dpi, ARM64, CoreCLR 11.0.0, SDK 11.0.100.

| Phase | Result |
| --- | --- |
| Unchanged original read-only Editor pair | Selection-length case times
out at the same line as CI; cursor-position case passes |
| Diagnostic trigger-removed control | Original pair: 2 passed |
| Fix applied | Original pair plus six focus cases: 8 passed |
| Only production guard reverted, final test bodies retained | 4 failed
/ 4 passed: original selection timeout and all three read-only
programmatic cases fail |
| Guard restored, no diagnostic app instrumentation | Same eight cases:
8 passed |
| Expanded selector including both Editor fixture names and Issue6250 |
93 total: 62 passed, 3 existing skips, 28 failed solely because
Material3 API-30 baseline snapshots are absent; no snapshots or filters
changed |
| Pushed commit rebuilt and identical expanded selector repeated | 93
total: 62 passed, 3 existing skips, 28 missing-baseline failures;
original Editor fixture 56 passed / 3 skips and Issue6250 6 passed |

Within that expanded run, the original Editor fixture is **56 passed / 3
existing skips** and Issue6250 is **6 passed**. The Material3 failures
are explicit validation limitations, not a green full-suite claim: those
snapshots exist under `android-notch-36`, not the API-30 `android`
directory.

The failing CI environment uses x86_64/CoreCLR 11.0.1/servicing SDK
11.0.101. Local ARM64 validation is not a claim that the exact CI
runtime or other platforms have passed. CI requests remain with the
coordinating maintainer/session. No manual CI or review triggers were
submitted.

Searched open and recently merged PRs for the failure, native
text-editor check, and explicit keyboard-show mechanism; #40191 is the
preceding focusability change, not a duplicate repair. #40169 changes
ContentView handling, not this focus path.

#### Exact commands and results

Run from the repository root using the local SDK/runtime and owned
emulator described above. Absolute paths below identify retained
diagnostic results; none of those diagnostic files is part of the PR.

**Passed: 0 warnings, 0 errors.**

```bash
dotnet build Microsoft.Maui.BuildTasks.slnf -c Debug -p:IncludeAndroidTargetFrameworks=true -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -v:q
```

**Passed, including the post-push build: 0 warnings, 0 errors.**

```bash
dotnet build src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj -c Debug -f net11.0-android -p:RuntimeIdentifier=android-arm64 -p:EmbedAssembliesIntoApk=true -p:UseMonoRuntime=false -p:IncludeAndroidTargetFrameworks=true -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -v:q
```

**Passed, including the post-push build: 0 warnings, 0 errors. The
external targets file changes only the task-owned Appium endpoint.**

```bash
dotnet build src/Controls/tests/TestCases.Android.Tests/Controls.TestCases.Android.Tests.csproj -c Debug -p:IncludeAndroidTargetFrameworks=true -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -p:CustomAfterMicrosoftCommonTargets=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/private-appium.targets -v:q
```

**Passed (exit 0); only these three changed C# files were included.**

```bash
dotnet format Microsoft.Maui.sln --no-restore --exclude Templates/src --exclude-diagnostics CA1822 --include src/Core/src/Platform/Android/TextViewExtensions.cs src/Controls/tests/TestCases.HostApp/Issues/Issue6250.cs src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue6250.cs --verbosity quiet
```

**Expected red with only the production guard removed: 4 failed / 4
passed / 0 skipped.**

```bash
DEVICE_UDID=emulator-5576 ANDROID_SERIAL=emulator-5576 PLATFORM_VERSION=11 DEVICE_SKIN='Nexus 5X' APPIUM_LOG_FILE=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-reverted-appium.log dotnet vstest artifacts/bin/Controls.TestCases.Android.Tests/Debug/net11.0/Controls.TestCases.Android.Tests.dll '--TestCaseFilter:FullyQualifiedName~VerifyEditorSelectionLengthWhenIsReadOnlyTrue|FullyQualifiedName~VerifyEditorCursorPositionWhenIsReadOnlyTrue|FullyQualifiedName~Microsoft.Maui.TestCases.Tests.Issues.Issue6250' '--logger:trx;LogFileName=final-reverted.trx' --ResultsDirectory:/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-reverted
```

**Guard restored: 8 passed / 0 failed / 0 skipped, including editable
programmatic-focus positive controls.**

```bash
DEVICE_UDID=emulator-5576 ANDROID_SERIAL=emulator-5576 PLATFORM_VERSION=11 DEVICE_SKIN='Nexus 5X' APPIUM_LOG_FILE=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-restored-appium.log dotnet vstest artifacts/bin/Controls.TestCases.Android.Tests/Debug/net11.0/Controls.TestCases.Android.Tests.dll '--TestCaseFilter:FullyQualifiedName~VerifyEditorSelectionLengthWhenIsReadOnlyTrue|FullyQualifiedName~VerifyEditorCursorPositionWhenIsReadOnlyTrue|FullyQualifiedName~Microsoft.Maui.TestCases.Tests.Issues.Issue6250' '--logger:trx;LogFileName=final-restored.trx' --ResultsDirectory:/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-restored
```

**Post-push full selector on a401a45:
exit 1, 62 passed / 28 failed / 3 existing skips / 93 total. Every
failure is a missing API-30 Material3 baseline; none is silently
excluded.**

```bash
DEVICE_UDID=emulator-5576 ANDROID_SERIAL=emulator-5576 PLATFORM_VERSION=11 DEVICE_SKIN='Nexus 5X' APPIUM_LOG_FILE=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/postpush-appium.log dotnet vstest artifacts/bin/Controls.TestCases.Android.Tests/Debug/net11.0/Controls.TestCases.Android.Tests.dll '--TestCaseFilter:FullyQualifiedName~EditorFeatureTests|FullyQualifiedName~Microsoft.Maui.TestCases.Tests.Issues.Issue6250' '--logger:trx;LogFileName=postpush.trx' --ResultsDirectory:/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/postpush
```

### 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. -->

Relates to #40116 and #40191. Repairs the independent Editor timeout
observed in the validation of #40248; it does not change Issue7556 or
attribute this failure to that PR's implementation.

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
KarthikRajaKalaimani pushed a commit to KarthikRajaKalaimani/maui that referenced this pull request Nov 26, 2026
<!-- 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).

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.

This is an explicitly coordinated release-candidate repair for dotnet#40116,
targeting the designated `candidate/11.0.1xx-sr2` branch.

### Description of Change

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

Only post the explicit soft-keyboard request from
`TextViewExtensions.Focus` when Android's native `OnCheckIsTextEditor()`
returns true, while preserving the existing `ShowSoftInputOnFocus` check
and normal focus request.

**Root cause:** dotnet#40191 intentionally keeps read-only inputs focusable
and hides an existing keyboard in the native focus-change handler.
However, the shared programmatic-focus callback subsequently posts
`ShowSoftInput` even when the native input has `KeyListener = null`,
`InputType = 0`, and `OnCheckIsTextEditor() == false`. This reopens the
keyboard. In the unchanged
`VerifyEditorSelectionLengthWhenIsReadOnlyTrue` test, the sample's
Update Cursor Selection button programmatically focuses the read-only
Editor; the keyboard then obscures `SelectionLengthEntry`, causing the
timeout at line 480.

Native tracing on API 30 confirmed the Editor is genuinely read-only and
remains focusable/focused while the IME changes from hidden to visible.
A diagnostic-only control removing the explicit keyboard-show trigger
clears the unchanged test. The fix does not revert read-only
focusability or alter cursor/selection mapping. No timeouts, retry
budgets, filters, or screenshot tolerances are changed; existing
assertions are retained and focus assertions are added.

Extend the existing Issue6250 page/tests rather than adding a fixture:
exercise touch and programmatic focus for read-only Entry, Editor, and
SearchBar. Each case first proves an editable Entry shows the keyboard;
the programmatic cases use `Focus()` for that positive control too. All
cases assert that the intended read-only control actually receives focus
and the keyboard disappears. The original Editor feature tests remain
unchanged.

**Local causal validation:** Android API 30, Nexus 5X, 1080x1920, 420
dpi, ARM64, CoreCLR 11.0.0, SDK 11.0.100.

| Phase | Result |
| --- | --- |
| Unchanged original read-only Editor pair | Selection-length case times
out at the same line as CI; cursor-position case passes |
| Diagnostic trigger-removed control | Original pair: 2 passed |
| Fix applied | Original pair plus six focus cases: 8 passed |
| Only production guard reverted, final test bodies retained | 4 failed
/ 4 passed: original selection timeout and all three read-only
programmatic cases fail |
| Guard restored, no diagnostic app instrumentation | Same eight cases:
8 passed |
| Expanded selector including both Editor fixture names and Issue6250 |
93 total: 62 passed, 3 existing skips, 28 failed solely because
Material3 API-30 baseline snapshots are absent; no snapshots or filters
changed |
| Pushed commit rebuilt and identical expanded selector repeated | 93
total: 62 passed, 3 existing skips, 28 missing-baseline failures;
original Editor fixture 56 passed / 3 skips and Issue6250 6 passed |

Within that expanded run, the original Editor fixture is **56 passed / 3
existing skips** and Issue6250 is **6 passed**. The Material3 failures
are explicit validation limitations, not a green full-suite claim: those
snapshots exist under `android-notch-36`, not the API-30 `android`
directory.

The failing CI environment uses x86_64/CoreCLR 11.0.1/servicing SDK
11.0.101. Local ARM64 validation is not a claim that the exact CI
runtime or other platforms have passed. CI requests remain with the
coordinating maintainer/session. No manual CI or review triggers were
submitted.

Searched open and recently merged PRs for the failure, native
text-editor check, and explicit keyboard-show mechanism; dotnet#40191 is the
preceding focusability change, not a duplicate repair. dotnet#40169 changes
ContentView handling, not this focus path.

#### Exact commands and results

Run from the repository root using the local SDK/runtime and owned
emulator described above. Absolute paths below identify retained
diagnostic results; none of those diagnostic files is part of the PR.

**Passed: 0 warnings, 0 errors.**

```bash
dotnet build Microsoft.Maui.BuildTasks.slnf -c Debug -p:IncludeAndroidTargetFrameworks=true -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -v:q
```

**Passed, including the post-push build: 0 warnings, 0 errors.**

```bash
dotnet build src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj -c Debug -f net11.0-android -p:RuntimeIdentifier=android-arm64 -p:EmbedAssembliesIntoApk=true -p:UseMonoRuntime=false -p:IncludeAndroidTargetFrameworks=true -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -v:q
```

**Passed, including the post-push build: 0 warnings, 0 errors. The
external targets file changes only the task-owned Appium endpoint.**

```bash
dotnet build src/Controls/tests/TestCases.Android.Tests/Controls.TestCases.Android.Tests.csproj -c Debug -p:IncludeAndroidTargetFrameworks=true -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -p:CustomAfterMicrosoftCommonTargets=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/private-appium.targets -v:q
```

**Passed (exit 0); only these three changed C# files were included.**

```bash
dotnet format Microsoft.Maui.sln --no-restore --exclude Templates/src --exclude-diagnostics CA1822 --include src/Core/src/Platform/Android/TextViewExtensions.cs src/Controls/tests/TestCases.HostApp/Issues/Issue6250.cs src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue6250.cs --verbosity quiet
```

**Expected red with only the production guard removed: 4 failed / 4
passed / 0 skipped.**

```bash
DEVICE_UDID=emulator-5576 ANDROID_SERIAL=emulator-5576 PLATFORM_VERSION=11 DEVICE_SKIN='Nexus 5X' APPIUM_LOG_FILE=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-reverted-appium.log dotnet vstest artifacts/bin/Controls.TestCases.Android.Tests/Debug/net11.0/Controls.TestCases.Android.Tests.dll '--TestCaseFilter:FullyQualifiedName~VerifyEditorSelectionLengthWhenIsReadOnlyTrue|FullyQualifiedName~VerifyEditorCursorPositionWhenIsReadOnlyTrue|FullyQualifiedName~Microsoft.Maui.TestCases.Tests.Issues.Issue6250' '--logger:trx;LogFileName=final-reverted.trx' --ResultsDirectory:/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-reverted
```

**Guard restored: 8 passed / 0 failed / 0 skipped, including editable
programmatic-focus positive controls.**

```bash
DEVICE_UDID=emulator-5576 ANDROID_SERIAL=emulator-5576 PLATFORM_VERSION=11 DEVICE_SKIN='Nexus 5X' APPIUM_LOG_FILE=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-restored-appium.log dotnet vstest artifacts/bin/Controls.TestCases.Android.Tests/Debug/net11.0/Controls.TestCases.Android.Tests.dll '--TestCaseFilter:FullyQualifiedName~VerifyEditorSelectionLengthWhenIsReadOnlyTrue|FullyQualifiedName~VerifyEditorCursorPositionWhenIsReadOnlyTrue|FullyQualifiedName~Microsoft.Maui.TestCases.Tests.Issues.Issue6250' '--logger:trx;LogFileName=final-restored.trx' --ResultsDirectory:/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/final-restored
```

**Post-push full selector on a401a45:
exit 1, 62 passed / 28 failed / 3 existing skips / 93 total. Every
failure is a missing API-30 Material3 baseline; none is silently
excluded.**

```bash
DEVICE_UDID=emulator-5576 ANDROID_SERIAL=emulator-5576 PLATFORM_VERSION=11 DEVICE_SKIN='Nexus 5X' APPIUM_LOG_FILE=/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/postpush-appium.log dotnet vstest artifacts/bin/Controls.TestCases.Android.Tests/Debug/net11.0/Controls.TestCases.Android.Tests.dll '--TestCaseFilter:FullyQualifiedName~EditorFeatureTests|FullyQualifiedName~Microsoft.Maui.TestCases.Tests.Issues.Issue6250' '--logger:trx;LogFileName=postpush.trx' --ResultsDirectory:/Users/kubaflo/.copilot/session-state/36c25d54-6d5a-4e42-8ee0-23fc24260ce9/files/postpush
```

### 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. -->

Relates to dotnet#40116 and dotnet#40191. Repairs the independent Editor timeout
observed in the validation of dotnet#40248; it does not change Issue7556 or
attribute this failure to that PR's implementation.

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

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-controls-entry Entry community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/android s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android: Numeric keyboard briefly shows alphanumeric keyboard before switching to numeric keyboard when Entry receives focus

4 participants