Skip to content

[Android] SafeArea: let empty insets reach tracked views so SoftInput padding resets - #39672

Merged
kubaflo merged 1 commit into
dotnet:inflight/candidatefrom
kevin68:fix-android-stale-softinput-padding
Oct 26, 2026
Merged

kubaflo merged 1 commit into
dotnet:inflight/candidatefrom
kevin68:fix-android-stale-softinput-padding

Conversation

@kevin68

@kevin68 kevin68 commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Description of Change

MauiWindowInsetListener.OnApplyWindowInsets returned early on !insets.HasInsets, before the view's IHandleWindowInsets handler. When the keyboard closes on a window with no system bars, every inset is zero. A view that still carries keyboard-height padding, and is therefore tracked, never got the dispatch that resets it, so the padding stayed for good.

The early return now applies only to views the listener does not track. A view with no applied padding has nothing to reset, so the existing short-circuit still saves it the work. A tracked view receives the empty insets, and SafeAreaExtensions.ApplyAdjustedSafeAreaInsetsPx already resets its padding to 0: a tracked view with every edge at 0 goes on to SetPadding(0, 0, 0, 0).

The IsImeAnimating gate is unchanged. During an animation, tracked views are still gated and get their settled insets from the end-of-animation re-apply, which this change now lets through.

Tests

MauiWindowInsetListenerTests.EmptyInsetsReachTrackedViewsOnly (Android device test) checks two things:

  • empty insets reach a tracked view's handler;
  • they are still skipped for an untracked one.

I ran the Category=Window device tests on a Samsung Galaxy Tab A11 (SM-X230, Android 16, API 36):

  • with the fix: 41/41 pass, all 7 MauiWindowInsetListenerTests included;
  • without the fix: EmptyInsetsReachTrackedViewsOnly fails (Expected: 1, Actual: 0), and every other test passes.

Issues Fixed

Fixes #39671

🤖 Generated with Claude Code

… padding resets

MauiWindowInsetListener returned early on !HasInsets, so on a window with no
system bars the dispatch that follows the keyboard closing never reached the
view still carrying keyboard-height padding.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kevin68
kevin68 temporarily deployed to copilot-pat-pool October 26, 2026 15:15 — with GitHub Actions Inactive
@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 -- 39672

Or

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

@azure-pipelines

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

@dotnet-policy-service dotnet-policy-service Bot added the community ✨ Community Contribution label Oct 26, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

@kevin68
kevin68 temporarily deployed to copilot-pat-pool October 26, 2026 15:15 — with GitHub Actions Inactive
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

@kevin68
kevin68 temporarily deployed to copilot-pat-pool October 26, 2026 15:16 — with GitHub Actions Inactive
@kevin68
kevin68 temporarily deployed to copilot-pat-pool October 26, 2026 15:18 — with GitHub Actions Inactive
@kubaflo

This comment has been minimized.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Oct 26, 2026
@kevin68
kevin68 temporarily deployed to copilot-pat-pool October 26, 2026 15:20 — with GitHub Actions Inactive
@kevin68
kevin68 temporarily deployed to copilot-pat-pool October 26, 2026 15:20 — with GitHub Actions Inactive
@azure-pipelines

This comment has been minimized.

@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 75bbaa8.

@MauiBot

MauiBot commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@kevin68 — existing-test verification for commit 75bbaa8b.

Result PASSED Platform Android Commit 75bbaa8b


🧪 Gate analysis — click to expand

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

📱 Device tests
Test group Without fix With fix
MauiWindowInsetListenerTests (EmptyInsetsReachTrackedViewsOnly) ✅ Failed as expected (415s) ✅ Passed (408s)
Execution log excerpts

Without fix MauiWindowInsetListenerTests (EmptyInsetsReachTrackedViewsOnly)

moryBytes": 8322998272
          },
          "target": {
            "kind": "emulator",
            "name": "sdk_gphone_x86_64",
            "identifier": "emulator-5554",
            "operatingSystem": "Android",
            "operatingSystemVersion": "11",
            "apiLevel": 30,
            "architecture": "x86_64",
            "supportedArchitectures": [
              "x86_64",
              "x86",
              "arm64-v8a",
              "armeabi-v7a",
              "armeabi"
            ],
            "manufacturer": "Google",
            "model": "sdk_gphone_x86_64",
            "productName": "sdk_gphone_x86_64",
            "buildFingerprint": "google/sdk_gphone_x86_64/generic_x86_64_arm64:11/RSR1.201211.001/7027799:user/release-keys",
            "cpuModel": "0",
            "cpuMaxFrequencyHertz": 2000,
            "totalMemoryBytes": 2077544448
          }
        }
      }
      <<XHARNESS_RESULT_END>>
info: Attempting to remove apk 'com.microsoft.maui.controls.devicetests'..
info: Successfully uninstalled com.microsoft.maui.controls.devicetests
XHarness exit code: 1 (TESTS_FAILED)
  Passed: 0
  Failed: 1
  Skipped: 0
  Total: 1
  Tests completed with exit code: 1

With fix MauiWindowInsetListenerTests (EmptyInsetsReachTrackedViewsOnly)

            "totalMemoryBytes": 8322998272
          },
          "target": {
            "kind": "emulator",
            "name": "sdk_gphone_x86_64",
            "identifier": "emulator-5554",
            "operatingSystem": "Android",
            "operatingSystemVersion": "11",
            "apiLevel": 30,
            "architecture": "x86_64",
            "supportedArchitectures": [
              "x86_64",
              "x86",
              "arm64-v8a",
              "armeabi-v7a",
              "armeabi"
            ],
            "manufacturer": "Google",
            "model": "sdk_gphone_x86_64",
            "productName": "sdk_gphone_x86_64",
            "buildFingerprint": "google/sdk_gphone_x86_64/generic_x86_64_arm64:11/RSR1.201211.001/7027799:user/release-keys",
            "cpuModel": "0",
            "cpuMaxFrequencyHertz": 2000,
            "totalMemoryBytes": 2077544448
          }
        }
      }
      <<XHARNESS_RESULT_END>>
info: Attempting to remove apk 'com.microsoft.maui.controls.devicetests'..
info: Successfully uninstalled com.microsoft.maui.controls.devicetests
XHarness exit code: 0
  Passed: 1
  Failed: 0
  Skipped: 0
  Total: 1
  Tests completed successfully

PR head: 75bbaa8b.

Without-fix baseline: 4781afbd.

@kubaflo
kubaflo changed the base branch from main to inflight/candidate October 26, 2026 21:54
@kubaflo
kubaflo merged commit 94a82d8 into dotnet:inflight/candidate Oct 26, 2026
201 of 212 checks passed
@github-actions github-actions Bot added this to the .NET 10 SR13 milestone Oct 26, 2026
github-actions Bot pushed a commit that referenced this pull request Oct 28, 2026
… padding resets (#39672)

### Description of Change

`MauiWindowInsetListener.OnApplyWindowInsets` returned early on
`!insets.HasInsets`, before the view's `IHandleWindowInsets` handler.
When the keyboard closes on a window with no system bars, every inset is
zero. A view that still carries keyboard-height padding, and is
therefore tracked, never got the dispatch that resets it, so the padding
stayed for good.

The early return now applies only to views the listener does not track.
A view with no applied padding has nothing to reset, so the existing
short-circuit still saves it the work. A tracked view receives the empty
insets, and `SafeAreaExtensions.ApplyAdjustedSafeAreaInsetsPx` already
resets its padding to 0: a tracked view with every edge at 0 goes on to
`SetPadding(0, 0, 0, 0)`.

The `IsImeAnimating` gate is unchanged. During an animation, tracked
views are still gated and get their settled insets from the
end-of-animation re-apply, which this change now lets through.

### Tests

`MauiWindowInsetListenerTests.EmptyInsetsReachTrackedViewsOnly` (Android
device test) checks two things:
- empty insets reach a tracked view's handler;
- they are still skipped for an untracked one.

I ran the `Category=Window` device tests on a Samsung Galaxy Tab A11
(SM-X230, Android 16, API 36):
- with the fix: 41/41 pass, all 7 `MauiWindowInsetListenerTests`
included;
- without the fix: `EmptyInsetsReachTrackedViewsOnly` fails (`Expected:
1, Actual: 0`), and every other test passes.

### Issues Fixed

Fixes #39671
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 26, 2026

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — 75bbaa8b Deployed Oct 26, 2026 by kevin68 via conclusion #2517
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

community ✨ Community Contribution 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] SoftInput padding stays after the keyboard closes when the window has no system bars

3 participants