Repository navigation
fix(CordovaActivity): adjust dispatched window insets for WebView margins - #2022
GitToTheHub wants to merge 2 commits into
Conversation
- Cordova moved the WebView away from system bars using margins, but the WebView could still receive those same insets. Pages using env(safe-area-inset-*) could then apply extra spacing for areas the WebView no longer overlapped. - `CordovaActivity` applies system-bar, display-cutout, and IME insets to the WebView’s margins and sizes the status-bar overlay. It then now dispatches adjusted insets to child views, subtracting the margin offsets already applied so those same offsets aren’t reported again to the WebView. Insets for areas where the WebView still draws edge-to-edge remain available to it. - Fixes `safe-area-inset-*` vars not 0 when `AndroidEdgeToEdge` is `false` - Fixes #2021 - Generated-By: GPT-6 Luna
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2022 +/- ##
=======================================
Coverage 63.20% 63.20%
=======================================
Files 24 24
Lines 4922 4922
=======================================
Hits 3111 3111
Misses 1811 1811 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
If no one has any objections, I would merge this |
|
I'm not sure why but applying this change appears to cause the software keyboard to cover up text inputs that are in the space where the keyboard will show when the text inputs are focused. Without this change, the webview automatically moves the page up so that the text input isn't covered by the keyboard. Tested on an Android 13 device with AndroidEdgeToEdge = true. |
|
Thanks for reporting this. I tested on Android 13 and 15 with WebView 149, plus WebView 109 on Android 13, with edge-to-edge enabled and disabled. The current change also reduces keyboard insets, although its purpose is to correct safe-area values. I’ve prepared a narrower adjustment that preserves keyboard insets. In my tests, safe-area values remain zero with edge-to-edge disabled, and keyboard resizing, typing, and dismissal work as expected. I haven’t reproduced your exact overlap issue with edge-to-edge enabled. Could you share your Android System WebView version and, if possible, a minimal HTML/CSS example? That would help verify whether the adjustment resolves your case. Also you could check a minimal Hello World app with no additional plugins. |
|
After testing again, the bug disappeared when I disabled a specific 3rd party cordova plugin so the bug is probably in that plugin and it's OnApplyWindowInsetsListener (cordova-plugin-admob-nextgen). |
|
Thanks for testing again and narrowing it down! That would explain why I couldn’t reproduce the issue without that plugin. Its |
Platforms affected
Android
Motivation and Context
env(safe-area-inset-*)could then apply extra spacing for areas the WebView no longer overlapped. See issue CSSsafe-area-inset-*vars not 0 whenAndroidEdgeToEdgeisfalse#2021 for more details.CordovaActivityapplies system-bar, display-cutout, and IME insets to the WebView’s margins and sizes the status-bar overlay. It then now dispatches adjusted insets to child views, subtracting the margin offsets already applied so those same offsets aren’t reported again to the WebView. Insets for areas where the WebView still draws edge-to-edge remain available to it.safe-area-inset-*vars not 0 whenAndroidEdgeToEdgeisfalse#2021Description
Testing
I tested it with
AndroidEdgeToEdgesetting tofalseandtrueon an Android 15 emulator.Setting
AndroidEdgeToEdgetofalsesetssafe-area-inset-*vars to 0:Setting
AndroidEdgeToEdgetotruesets thesafe-area-inset-*vars to the excepted values, for e.g.safe-area-inset-topis set to55pxon portrait:Checklist
(platform)if this change only applies to one platform (e.g.(android))