web: ride bottom chrome and omnibox above the keyboard
- Commit
8eea57b19b812242e2c69187b1eb5c366fef17e9- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-02 03:02 UTC (4 days ago)
- Parents
53cc47a
With the toolbar at the bottom (or bottom-docked omnibox editing), opening the keyboard left the bar at the physical bottom of the screen, hidden under the IME, and left the WebView extending behind the keyboard so page inputs were covered. Root cause: a bar in Scaffold's bottomBar slot must claim its own insets. The shared library Scaffold unions IME into the content insets, but M3 Scaffold replaces the content's bottom inset with the bottom bar's measured height and never lifts the bar itself. Both bottom bars only applied navigationBarsPadding, based on the stale assumption that MainNavigation owned the IME inset (it no longer does). The standalone PWA window has no Scaffold at all and only applied statusBarsPadding, so its WebView was covered too. Fix, following the library.ui BottomAppBar/BottomNavBar pattern: the bottom browser chrome and the bottom omnibox editor now pad by WindowInsets.navigationBars union WindowInsets.ime (union, not sum, since a visible keyboard already covers the navigation bar), so each bar sits flush on top of the keyboard with no gap. Because Scaffold insets the content by the bar's full measured height, padding included, the page content is not double-padded. The PWA container adds imePadding, which is zero while the keyboard is hidden, so its edge-to-edge layout is unchanged. Top-docked chrome and the top omnibox editor already resized correctly through the Scaffold content insets and are untouched, as is the omnibox SCAFFOLD SEARCH EXCEPTION design. Verified: :web:testDevUnitTest green (compiles the change). :web:lint and :web:lintVitalRelease are red on pre-existing backlog only (DialogAsRoute, FixtureDeterminism and RouteScreenshotCoverage errors in files this change does not touch); no lint finding references the three changed files.
Diff
web/src/main/java/com/vayunmathur/web/platform/PwaBrowser.kt
diff --git a/web/src/main/java/com/vayunmathur/web/platform/PwaBrowser.kt b/web/src/main/java/com/vayunmathur/web/platform/PwaBrowser.ktindex 8c33d86d4b..d63a6fac8f 100644--- a/web/src/main/java/com/vayunmathur/web/platform/PwaBrowser.kt+++ b/web/src/main/java/com/vayunmathur/web/platform/PwaBrowser.kt@@ -27,6 +27,7 @@ import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.contract.ActivityResultContracts import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.imePadding import androidx.compose.foundation.layout.statusBarsPadding import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue@@ -111,7 +112,11 @@ internal fun PwaBrowser( PwaBackHandler(activity, deps) { webViewRef } - Box(modifier = modifier.fillMaxSize().statusBarsPadding()) {+ // No Scaffold here (chromeless window), so nothing else owns the IME inset:+ // imePadding shrinks the WebView above the keyboard when a page input is+ // focused, instead of the keyboard covering the page's bottom. It is zero+ // while the keyboard is hidden, so the edge-to-edge layout is unchanged.+ Box(modifier = modifier.fillMaxSize().statusBarsPadding().imePadding()) { AndroidView( modifier = Modifier.fillMaxSize(), factory = { ctx ->
web/src/main/java/com/vayunmathur/web/ui/BrowserChrome.kt
diff --git a/web/src/main/java/com/vayunmathur/web/ui/BrowserChrome.kt b/web/src/main/java/com/vayunmathur/web/ui/BrowserChrome.ktindex 4600f4efcf..4c470f2686 100644--- a/web/src/main/java/com/vayunmathur/web/ui/BrowserChrome.kt+++ b/web/src/main/java/com/vayunmathur/web/ui/BrowserChrome.kt@@ -12,8 +12,11 @@ import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.consumeWindowInsets import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height-import androidx.compose.foundation.layout.navigationBarsPadding+import androidx.compose.foundation.layout.ime+import androidx.compose.foundation.layout.navigationBars import androidx.compose.foundation.layout.statusBars+import androidx.compose.foundation.layout.union+import androidx.compose.foundation.layout.windowInsetsPadding import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape@@ -75,14 +78,22 @@ internal fun BrowserChrome( // At the bottom, TopAppBar's hardcoded top inset would be a status bar's // height of dead space, and nothing else applies the navigation bar inset. // The bar's own container color stops at the padding, so the surface is- // painted here instead to reach the screen edge. The IME inset is left alone- // on purpose: MainNavigation already owns it, and navigationBarsPadding- // resolves to zero once the keyboard has consumed more than a navigation- // bar's height.+ // painted here instead to reach the screen edge.+ //+ // A bar in Scaffold's bottomBar slot must claim its insets itself: the+ // shared Scaffold wrapper unions IME into the *content* insets, but M3+ // Scaffold replaces the content's bottom inset with the bottom bar's+ // measured height and never lifts the bar itself. So the bottom bar+ // pads by navigationBars ∪ ime (union, not sum — a visible keyboard+ // already covers the navigation bar), exactly like library.ui's+ // BottomAppBar/BottomNavBar. That rides the bar flush onto the+ // keyboard with no gap, and because Scaffold then insets the content+ // by the bar's full measured height (padding included), the page is+ // not double-padded either. val barModifier = if (atBottom) { Modifier .background(MaterialTheme.colorScheme.surface)- .navigationBarsPadding()+ .windowInsetsPadding(WindowInsets.navigationBars.union(WindowInsets.ime)) .consumeWindowInsets(WindowInsets.statusBars) } else { Modifier
web/src/main/java/com/vayunmathur/web/ui/BrowserOmniboxEditor.kt
diff --git a/web/src/main/java/com/vayunmathur/web/ui/BrowserOmniboxEditor.kt b/web/src/main/java/com/vayunmathur/web/ui/BrowserOmniboxEditor.ktindex c6ebd003bd..ab1036e3ec 100644--- a/web/src/main/java/com/vayunmathur/web/ui/BrowserOmniboxEditor.kt+++ b/web/src/main/java/com/vayunmathur/web/ui/BrowserOmniboxEditor.kt@@ -7,8 +7,11 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth-import androidx.compose.foundation.layout.navigationBarsPadding+import androidx.compose.foundation.layout.ime+import androidx.compose.foundation.layout.navigationBars import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.union+import androidx.compose.foundation.layout.windowInsetsPadding import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions@@ -146,8 +149,15 @@ internal fun OmniboxEditor( bottomBar = { Surface(Modifier.fillMaxWidth()) { Row(+ // bottomBar slot: Scaffold insets only the content,+ // never lifts the bar — so the editing bar claims+ // navigationBars ∪ ime itself (union, not sum: the+ // keyboard already covers the nav bar), riding flush+ // onto the keyboard instead of hiding under it. The+ // suggestions' bottom padding is this bar's measured+ // height, so nothing is double-padded. modifier = Modifier- .navigationBarsPadding()+ .windowInsetsPadding(WindowInsets.navigationBars.union(WindowInsets.ime)) .padding(start = 4.dp, end = 12.dp, top = 4.dp, bottom = 4.dp), verticalAlignment = Alignment.CenterVertically, ) {