fix(omnibox): improve layout with max width constraint and consistent row heights
- commit
- 56e959cc0ab0d652a72fac110ea9ff240ea81c2c
- author
- brice · · 2025-12-16 21:41 UTC
- committer
- brice · · 2025-12-16 21:51 UTC
- parent
- fa675ef
- signature
- unsigned
2 files · +8 -0
M internal/ui/component/omnibox.go +7 -0
| @@ -20,6 +20,7 @@ import ( | |||
| 20 | 20 | ||
| 21 | 21 | const ( | |
| 22 | 22 | omniboxWidthPct = 0.8 // 80% of parent window width | |
| 23 | + | omniboxMaxWidth = 800 // Maximum width in pixels | |
| 23 | 24 | omniboxHeightPct = 0.6 // 60% of parent window height | |
| 24 | 25 | omniboxMaxResults = 10 | |
| 25 | 26 | debounceDelayMs = 150 | |
| @@ -199,6 +200,9 @@ func (o *Omnibox) resizeAndCenter(rowCount int) { | |||
| 199 | 200 | } | |
| 200 | 201 | ||
| 201 | 202 | width := int(float64(parentWidth) * omniboxWidthPct) | |
| 203 | + | if width > omniboxMaxWidth { | |
| 204 | + | width = omniboxMaxWidth | |
| 205 | + | } | |
| 202 | 206 | ||
| 203 | 207 | // Cap at max results | |
| 204 | 208 | if rowCount > omniboxMaxResults { | |
| @@ -1134,6 +1138,9 @@ func (o *Omnibox) Show(ctx context.Context, query string) { | |||
| 1134 | 1138 | parentWidth := o.parentOverlay.GetAllocatedWidth() | |
| 1135 | 1139 | parentHeight := o.parentOverlay.GetAllocatedHeight() | |
| 1136 | 1140 | width := int(float64(parentWidth) * omniboxWidthPct) | |
| 1141 | + | if width > omniboxMaxWidth { | |
| 1142 | + | width = omniboxMaxWidth | |
| 1143 | + | } | |
| 1137 | 1144 | marginTop := int(float64(parentHeight) * 0.20) // 20% from top | |
| 1138 | 1145 | ||
| 1139 | 1146 | o.mainBox.SetSizeRequest(width, -1) | |
| @@ -20,6 +20,7 @@ import ( | |||||
| 20 | 20 | ||||
| 21 | const ( | 21 | const ( | ||
| 22 | omniboxWidthPct = 0.8 // 80% of parent window width | 22 | omniboxWidthPct = 0.8 // 80% of parent window width | ||
| 23 | + | omniboxMaxWidth = 800 // Maximum width in pixels | |||
| 23 | omniboxHeightPct = 0.6 // 60% of parent window height | 24 | omniboxHeightPct = 0.6 // 60% of parent window height | ||
| 24 | omniboxMaxResults = 10 | 25 | omniboxMaxResults = 10 | ||
| 25 | debounceDelayMs = 150 | 26 | debounceDelayMs = 150 | ||
| @@ -199,6 +200,9 @@ func (o *Omnibox) resizeAndCenter(rowCount int) { | |||||
| 199 | } | 200 | } | ||
| 200 | 201 | ||||
| 201 | width := int(float64(parentWidth) * omniboxWidthPct) | 202 | width := int(float64(parentWidth) * omniboxWidthPct) | ||
| 203 | + | if width > omniboxMaxWidth { | |||
| 204 | + | width = omniboxMaxWidth | |||
| 205 | + | } | |||
| 202 | 206 | ||||
| 203 | // Cap at max results | 207 | // Cap at max results | ||
| 204 | if rowCount > omniboxMaxResults { | 208 | if rowCount > omniboxMaxResults { | ||
| @@ -1134,6 +1138,9 @@ func (o *Omnibox) Show(ctx context.Context, query string) { | |||||
| 1134 | parentWidth := o.parentOverlay.GetAllocatedWidth() | 1138 | parentWidth := o.parentOverlay.GetAllocatedWidth() | ||
| 1135 | parentHeight := o.parentOverlay.GetAllocatedHeight() | 1139 | parentHeight := o.parentOverlay.GetAllocatedHeight() | ||
| 1136 | width := int(float64(parentWidth) * omniboxWidthPct) | 1140 | width := int(float64(parentWidth) * omniboxWidthPct) | ||
| 1141 | + | if width > omniboxMaxWidth { | |||
| 1142 | + | width = omniboxMaxWidth | |||
| 1143 | + | } | |||
| 1137 | marginTop := int(float64(parentHeight) * 0.20) // 20% from top | 1144 | marginTop := int(float64(parentHeight) * 0.20) // 20% from top | ||
| 1138 | 1145 | ||||
| 1139 | o.mainBox.SetSizeRequest(width, -1) | 1146 | o.mainBox.SetSizeRequest(width, -1) | ||
M internal/ui/theme/css.go +1 -0
| @@ -201,6 +201,7 @@ entry.omnibox-entry > *:focus-visible { | |||
| 201 | 201 | border-left: 0.1875em solid transparent; | |
| 202 | 202 | border-bottom: 0.0625em solid alpha(var(--border), 0.5); | |
| 203 | 203 | transition: background-color 100ms ease-in-out, border-left-color 100ms ease-in-out; | |
| 204 | + | min-height: 2.75em; | |
| 204 | 205 | } | |
| 205 | 206 | ||
| 206 | 207 | .omnibox-row:last-child { | |
| @@ -201,6 +201,7 @@ entry.omnibox-entry > *:focus-visible { | |||||
| 201 | border-left: 0.1875em solid transparent; | 201 | border-left: 0.1875em solid transparent; | ||
| 202 | border-bottom: 0.0625em solid alpha(var(--border), 0.5); | 202 | border-bottom: 0.0625em solid alpha(var(--border), 0.5); | ||
| 203 | transition: background-color 100ms ease-in-out, border-left-color 100ms ease-in-out; | 203 | transition: background-color 100ms ease-in-out, border-left-color 100ms ease-in-out; | ||
| 204 | + | min-height: 2.75em; | |||
| 204 | } | 205 | } | ||
| 205 | 206 | ||||
| 206 | .omnibox-row:last-child { | 207 | .omnibox-row:last-child { | ||