Skip to content

fix(SystemBars): avoid extra IME padding on API <= 34 in insets passthrough - #8528

Open
MedOussemaNjimi wants to merge 1 commit into
ionic-team:mainfrom
MedOussemaNjimi:fix/systembars-ime-padding-api34
Open

fix(SystemBars): avoid extra IME padding on API <= 34 in insets passthrough#8528
MedOussemaNjimi wants to merge 1 commit into
ionic-team:mainfrom
MedOussemaNjimi:fix/systembars-ime-padding-api34

Conversation

@MedOussemaNjimi

@MedOussemaNjimi MedOussemaNjimi commented Jul 12, 2026

Copy link
Copy Markdown

Fixes #8525

What

Gates the IME padding in the insets passthrough branch of SystemBars (WebView >= 140 + viewport-fit=cover) behind Build.VERSION.SDK_INT >= VANILLA_ICE_CREAM, the same gate that #8439 added to the non-passthrough branch.

Why

Since 8.3.0 (#8384), when an input is focused on Android 10, a gray area the height of the keyboard appears above the keyboard — reproducible with a fresh npm init @capacitor/app@latest app (whose template uses viewport-fit=cover, so the passthrough branch is taken on devices with WebView >= 140).

On API <= 34 Capacitor does not run edge-to-edge, so the system already resizes the window when the IME is shown. On API 29 the compat WindowInsetsCompat.Type.ime() insets are still reported as the keyboard height after that resize, so v.setPadding(0, 0, 0, imeInsets.bottom) compensated for the keyboard a second time, producing the extra gray space. (On API 30–34 the dispatched IME insets are already consumed after the resize, which is why those versions were unaffected.)

#8439 fixed the exact same double-compensation in the non-passthrough branch; the passthrough branch added later in #8424 reintroduced it without the SDK gate. This PR applies the same gate there.

On API 35+ (enforced edge-to-edge) the behavior is unchanged.

Testing

  • ./gradlew compileReleaseJavaWithJavac -b capacitor/build.gradle passes.
  • Repro per the issue: npm init @capacitor/app@latest, add an input field, run on Android 10 — the gray space above the keyboard no longer appears, while API 35+ keyboard handling is untouched.

…hrough

On API <= 34 the window is not edge-to-edge, so the system already
resizes the window when the keyboard is shown. Adding imeInsets.bottom
as view padding in the insets passthrough branch doubled the space,
leaving a gray area the height of the keyboard above it (seen on
Android 10, where the compat IME insets are non-zero after the window
resize).

This applies the same SDK gate that ionic-team#8439 added to the non-passthrough
branch.

Fixes ionic-team#8525
@MedOussemaNjimi
MedOussemaNjimi force-pushed the fix/systembars-ime-padding-api34 branch from bb8c346 to b5069f6 Compare July 12, 2026 17:06
.build();
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

fabiomartino added a commit to fabiomartino/capacitor that referenced this pull request Aug 23, 2026
Resolve the SystemBars.java three-way conflict keeping the automatic
edge-to-edge and universal keyboard architecture from this branch
(ionic-team#8366) while adopting upstream's structural changes:

- insetsHandling as a validated string field with Logger.warn fallback
  (upstream ionic-team#8481), replacing the boolean gate across listener
  registration, initial CSS variables, and onDOMReady
- separate status bar and gesture bar style tracking (upstream ionic-team#8409)
- per-bar show/hide with else-if semantics (upstream ionic-team#8480)
- viewport JS text block TODO note for the future 'full' option

Fold in compatible ideas from open PR ionic-team#8454:
- navBarVisible tracking in setHidden so hidden navigation bars do not
  contribute phantom bottom insets
- navigation_bar_height resource fallback for legacy (API < 30) OEM
  builds reporting zero-height nav insets, suppressed for lint
  (InternalInsetResource, DiscouragedApi) since no supported API
  exposes a static navigation bar height
- IME visibility fallback below Android O via ime inset bottom > 0
- store requested styles so DEFAULT keeps following system theme
  changes when reapplied on configuration change or resume

PR ionic-team#8528's SDK gate for IME padding needs no code here: this branch
never applies window IME padding (keyboard is handled via CSS
variables and the inset builder), so double keyboard spacing on
API <= 34 cannot occur.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Capacitor v8.3.0 extra gray space when keyboard is visible

3 participants