Modern Apps git

← Modern-Apps.git

web: make the omnibox exactly as tall as the tab-count circle (#omnibox)

Commit
5efdeadc1cbcbfe7ef6f3a6f7f2de36fa47541b4
Author
Vayun Mathur <[email protected]>
When
2026-11-16 17:24 UTC (19 days ago)
Parents
e94141f
The address pill was a default-height (56.dp) OutlinedTextField
sitting next to a tab-count indicator that was 36.dp tall and only
pill-shaped: its width grew with the digit count, so the two
controls in one bar had neither the same height nor a stable
indicator shape.

Both now share ChromeControlHeight (36.dp) in BrowserChrome: the
indicator is a fixed-size CircleShape with its labelLarge count
centred, and the read-only omnibox field is constrained to the
same height. 36.dp is the height the indicator already had
(labelLarge line height plus its old vertical padding), so the
indicator's touch height is unchanged and no text shrinks: the
omnibox keeps its bodySmall text at the same size, only the
field's vertical padding gives up the extra height. There is no
shared control-size dimension in the repo (library.ui.Spacing is
spacing only), so the constant lives with the one bar that uses
it, shared by both controls.

Test: BrowserChromeAndSiteIconTest asserts the omnibox and tab
count bounds have equal height and that the indicator stays
square with a two-digit count. Verified:
:web:testDevUnitTest (BrowserChromeAndSiteIconTest) green.

Diff

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 1c5a150fd4..2aa0f9daef 100644--- a/web/src/main/java/com/vayunmathur/web/ui/BrowserChrome.kt+++ b/web/src/main/java/com/vayunmathur/web/ui/BrowserChrome.kt@@ -4,6 +4,7 @@ import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.WindowInsets@@ -11,11 +12,12 @@ 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.padding import androidx.compose.foundation.layout.statusBars import androidx.compose.foundation.layout.width+import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.runtime.Composable+import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.res.stringResource@@ -34,6 +36,17 @@ import com.vayunmathur.library.ui.TopAppBarDefaults import com.vayunmathur.library.ui.appBarScrollBehavior import com.vayunmathur.web.R +/**+ * Diameter of the circular tab-count indicator, and therefore the+ * height of the omnibox beside it: the two chrome controls share one+ * size so the bar reads as one row of equal-height controls. This is+ * the height the indicator already had (labelLarge line height plus+ * its old 8.dp vertical padding), so only the width stops varying+ * with the digit count. No shared repo dimension exists for this —+ * `library.ui.Spacing` is spacing, not control sizes.+ */+internal val ChromeControlHeight = 36.dp+ @OptIn(ExperimentalMaterial3Api::class) @Composable internal fun BrowserChrome(@@ -83,18 +96,25 @@ internal fun BrowserChrome(                     )                 },                 actions = {+                    // A true circle of ChromeControlHeight diameter, not a+                    // pill whose width grows with the digit count. The+                    // clickable area is exactly the circle it was before+                    // (same height) inside the TopAppBar row.                     Surface(-                        shape = RoundedCornerShape(20.dp),+                        shape = CircleShape,                         color = MaterialTheme.colorScheme.secondaryContainer,                         modifier = Modifier-                            .clip(RoundedCornerShape(20.dp))+                            .size(ChromeControlHeight)+                            .clip(CircleShape)                             .clickable(onClick = onTabSwitcherClick)                     ) {-                        Text(-                            text = tabCount.toString(),-                            style = MaterialTheme.typography.labelLarge,-                            modifier = Modifier.padding(horizontal = 14.dp, vertical = 8.dp)-                        )+                        Box(contentAlignment = Alignment.Center) {+                            Text(+                                text = tabCount.toString(),+                                style = MaterialTheme.typography.labelLarge,+                                maxLines = 1,+                            )+                        }                     }                     Spacer(Modifier.width(4.dp))                     IconButton(onClick = onMenuClick) { IconMoreVert() }@@ -126,8 +146,10 @@ private fun DisplayOnlyAddressPill(     onClick: () -> Unit,     modifier: Modifier = Modifier, ) {-    // Now matches CommonSearchBar visually: OutlinedTextField 28dp rounded, same padding.-    // bodySmall keeps the bar slim so more of the URL fits horizontally.+    // Exactly as tall as the circular tab-count indicator beside it+    // (ChromeControlHeight): the field's container shrinks and its+    // internal vertical padding with it, while the text stays bodySmall+    // at the same size — only padding was spent on the extra height.     Box(modifier = modifier) {         OutlinedTextField(             value = fullUrl,@@ -137,7 +159,7 @@ private fun DisplayOnlyAddressPill(             placeholder = { Text(stringResource(R.string.search_or_enter_address), style = MaterialTheme.typography.bodySmall) },             singleLine = true,             shape = RoundedCornerShape(28.dp),-            modifier = Modifier.fillMaxWidth()+            modifier = Modifier.fillMaxWidth().height(ChromeControlHeight)         )         // Overlay to handle tap without focusing the field         Box(
web/src/test/java/com/vayunmathur/web/ui/BrowserChromeAndSiteIconTest.kt
diff --git a/web/src/test/java/com/vayunmathur/web/ui/BrowserChromeAndSiteIconTest.kt b/web/src/test/java/com/vayunmathur/web/ui/BrowserChromeAndSiteIconTest.ktindex 6c37c32262..37ccb4ee86 100644--- a/web/src/test/java/com/vayunmathur/web/ui/BrowserChromeAndSiteIconTest.kt+++ b/web/src/test/java/com/vayunmathur/web/ui/BrowserChromeAndSiteIconTest.kt@@ -54,6 +54,23 @@ class BrowserChromeAndSiteIconTest {         rule.onNodeWithText("Search or enter address").assertIsDisplayed()     } +    @Test fun omniboxHeightMatchesTabCountDiameter() {+        rule.setContent {+            BrowserChrome(+                omniboxText = "https://example.com/page",+                tabCount = 12,+                progress = 0f,+            ) { padding -> androidx.compose.foundation.layout.Box(androidx.compose.ui.Modifier.padding(padding)) {} }+        }+        rule.waitForIdle()+        val tabBounds = rule.onNodeWithText("12").fetchSemanticsNode().boundsInRoot+        val fieldBounds = rule.onNodeWithText("https://example.com/page").fetchSemanticsNode().boundsInRoot+        // Same height on both controls, and the tab indicator is a square+        // (circle) even with a two-digit count.+        kotlin.test.assertEquals(tabBounds.height, fieldBounds.height)+        kotlin.test.assertEquals(tabBounds.width, tabBounds.height)+    }+     @Test fun siteIconShowsInitialForLabel() {         rule.setContent { SiteIcon(icon = null, label = "example") }         rule.waitForIdle()