Conversation
On API 29 the window is already resized by the system when the keyboard opens (windowSoftInputMode="adjustResize"), and WindowInsetsCompat can only approximate the ime() inset there. SystemBars additionally applied that approximated height as bottom padding, so the WebView was shrunk twice and collapsed to a few hundred pixels whenever WebView >= 140 and viewport-fit=cover were in use. After a rotation with the keyboard open the stale padding stuck until the app was restarted. Only apply the IME padding on API 30+, where ime() reports the real overlap. Verified on a Huawei MAR-LX1A (Android 10, WebView 152): window.innerHeight with the keyboard open is now 442 instead of 141 CSS px, and rotating with the keyboard open no longer leaves the WebView stuck. Behaviour on API 30+ is unchanged. Fixes ionic-team#8601 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #8601
What
SystemBars.initWindowInsetsListenerapplies theime()inset as bottom padding while the keyboard is visible. On API 29 that padding is applied on top of a window the system has already resized for the keyboard (windowSoftInputMode="adjustResize"), andWindowInsetsCompat.Type.ime()is only an approximation below API 30. The WebView is therefore shrunk twice.This PR only applies the IME padding on API 30+, where
ime()reports the real overlap. Both padding sites in the listener (passthrough and non-passthrough branch) use the same guard. Behaviour on API 30+ is unchanged.Reproduction
viewport-fit=cover@capacitor/android8.4.1 and 8.5.2 both affectedwindow.innerHeightdrops from 743 to 141 CSS px instead of the expected ~443;dumpsys activity topshows the parent at full height (0,0-1080,2231) andCapacitorWebViewat0,0-1080,327.Newer devices (API 30+) are not affected because
ime()reports the correct value there, and the Google API 29 emulator image ships WebView 91 (< 140), so the passthrough branch never runs on it — a physical device with a Play Store WebView is needed to reproduce.Verification
Applied via patch-package to
@capacitor/android8.4.1 in a production app and tested on a Huawei MAR-LX1A (Android 10, WebView 152):innerHeight141, footer hiddencompileReleaseJavaWithJavac,testReleaseUnitTestand the Prettier Java check pass. The non-passthrough branch (WebView < 140) received the same guard for consistency but was not exercised on a device.🤖 Generated with Claude Code