detached c7a2676

fix: improve omnibox width calculation for unallocated parents

commit
c7a267600186ac8bb91e3daad3c658509a680342
author
brice · · 2026-01-26 05:18 UTC
parent
c7a34e5
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
2 files · +10 -8
M internal/ui/component/modal_sizing.go +4 -2
@@ -90,10 +90,12 @@ func CalculateModalDimensions(parent layout.OverlayWidget, cfg ModalSizeConfig)
9090 parentHeight = parent.GetAllocatedHeight()
9191 }
9292
93- if parentWidth <= 0 {
93+ // Use fallback if parent not allocated or too small to be useful
94+ // A width < 100 is too small for any meaningful modal
95+ if parentWidth < 100 {
9496 parentWidth = cfg.FallbackWidth
9597 }
96- if parentHeight <= 0 {
98+ if parentHeight < 100 {
9799 parentHeight = cfg.FallbackHeight
98100 }
99101
@@ -90,10 +90,12 @@ func CalculateModalDimensions(parent layout.OverlayWidget, cfg ModalSizeConfig)
90 parentHeight = parent.GetAllocatedHeight()90 parentHeight = parent.GetAllocatedHeight()
91 }91 }
92 92
93- if parentWidth <= 0 {93+ // Use fallback if parent not allocated or too small to be useful
94+ // A width < 100 is too small for any meaningful modal
95+ if parentWidth < 100 {
94 parentWidth = cfg.FallbackWidth96 parentWidth = cfg.FallbackWidth
95 }97 }
96- if parentHeight <= 0 {98+ if parentHeight < 100 {
97 parentHeight = cfg.FallbackHeight99 parentHeight = cfg.FallbackHeight
98 }100 }
99 101
M internal/ui/component/omnibox.go +6 -6
@@ -307,24 +307,21 @@ func (o *Omnibox) resizeAndCenter(rowCount int) {
307307 return
308308 }
309309
310- // Calculate width using shared helper
311- width, _ := CalculateModalDimensions(o.parentOverlay, OmniboxSizeDefaults)
312-
313310 // Cap at max results
314311 if rowCount > OmniboxListDefaults.MaxVisibleRows {
315312 rowCount = OmniboxListDefaults.MaxVisibleRows
316313 }
317314
318315 // Schedule measurement after GTK has laid out widgets
319- // This ensures we get accurate heights from actual rendered content
320316 var cb glib.SourceFunc = func(uintptr) bool {
317+ width, _ := CalculateModalDimensions(o.parentOverlay, OmniboxSizeDefaults)
321318 o.measureAndResize(width, rowCount)
322- return false // One-shot
319+ return false
323320 }
324321 glib.IdleAdd(&cb, 0)
325322 }
326323
327-// measureAndResize calculates and sets the omnibox height based on row count.
324+// measureAndResize calculates and sets the omnibox size based on content.
328325 // Uses measured widget heights when available, falls back to estimates.
329326 func (o *Omnibox) measureAndResize(width, rowCount int) {
330327 if o.outerBox == nil || o.mainBox == nil {
@@ -333,6 +330,9 @@ func (o *Omnibox) measureAndResize(width, rowCount int) {
333330
334331 log := logging.FromContext(o.ctx)
335332
333+ // Apply width to mainBox - this allows the omnibox to adapt when parent resizes
334+ o.mainBox.SetSizeRequest(width, -1)
335+
336336 var rowHeight int
337337
338338 if o.measuredHeights.valid && o.measuredHeights.singleRow > 0 {
@@ -307,24 +307,21 @@ func (o *Omnibox) resizeAndCenter(rowCount int) {
307 return307 return
308 }308 }
309 309
310- // Calculate width using shared helper
311- width, _ := CalculateModalDimensions(o.parentOverlay, OmniboxSizeDefaults)
312-
313 // Cap at max results310 // Cap at max results
314 if rowCount > OmniboxListDefaults.MaxVisibleRows {311 if rowCount > OmniboxListDefaults.MaxVisibleRows {
315 rowCount = OmniboxListDefaults.MaxVisibleRows312 rowCount = OmniboxListDefaults.MaxVisibleRows
316 }313 }
317 314
318 // Schedule measurement after GTK has laid out widgets315 // Schedule measurement after GTK has laid out widgets
319- // This ensures we get accurate heights from actual rendered content
320 var cb glib.SourceFunc = func(uintptr) bool {316 var cb glib.SourceFunc = func(uintptr) bool {
317+ width, _ := CalculateModalDimensions(o.parentOverlay, OmniboxSizeDefaults)
321 o.measureAndResize(width, rowCount)318 o.measureAndResize(width, rowCount)
322- return false // One-shot319+ return false
323 }320 }
324 glib.IdleAdd(&cb, 0)321 glib.IdleAdd(&cb, 0)
325 }322 }
326 323
327-// measureAndResize calculates and sets the omnibox height based on row count.324+// measureAndResize calculates and sets the omnibox size based on content.
328 // Uses measured widget heights when available, falls back to estimates.325 // Uses measured widget heights when available, falls back to estimates.
329 func (o *Omnibox) measureAndResize(width, rowCount int) {326 func (o *Omnibox) measureAndResize(width, rowCount int) {
330 if o.outerBox == nil || o.mainBox == nil {327 if o.outerBox == nil || o.mainBox == nil {
@@ -333,6 +330,9 @@ func (o *Omnibox) measureAndResize(width, rowCount int) {
333 330
334 log := logging.FromContext(o.ctx)331 log := logging.FromContext(o.ctx)
335 332
333+ // Apply width to mainBox - this allows the omnibox to adapt when parent resizes
334+ o.mainBox.SetSizeRequest(width, -1)
335+
336 var rowHeight int336 var rowHeight int
337 337
338 if o.measuredHeights.valid && o.measuredHeights.singleRow > 0 {338 if o.measuredHeights.valid && o.measuredHeights.singleRow > 0 {

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 8

Tags 42

↑↓ moveenter openesc close