Skip to content

fix(toolbar): fit quick switcher height to its results, cap at 9 rows (#1349)#1392

Merged
datlechin merged 2 commits into
mainfrom
fix/quick-switcher-empty-space
May 22, 2026
Merged

fix(toolbar): fit quick switcher height to its results, cap at 9 rows (#1349)#1392
datlechin merged 2 commits into
mainfrom
fix/quick-switcher-empty-space

Conversation

@datlechin
Copy link
Copy Markdown
Member

@datlechin datlechin commented May 22, 2026

What

The quick switcher (Cmd+Shift+O) showed a large empty area below its results. With a few or no matches, most of the panel was blank.

Closes #1349.

Root cause

QuickSwitcherSheet pinned the whole panel to .frame(width: 460, height: 500). A SwiftUI List expands to fill the height it is offered and never shrinks to its content, so short result lists left the rest of the 500pt empty.

Fix

  • Drop the fixed height; the sheet sizes to its content (.frame(width:) only).
  • Add QuickSwitcherViewModel.listHeight(rowHeight:headerHeight:maxVisibleRows:): it computes the natural content height (items + section headers) and clamps it to a single cap of maxVisibleRows * rowHeight (9 rows), then the list scrolls. Headers count toward the cap, so a dense empty-query view can never overshoot.
  • Pin each row to a fixed height (drop the vertical padding, zero the vertical row insets) so the height math is exact.
  • Loading and "no results" states self-size instead of filling the panel.
  • isLoading starts true so the panel shows the loading state on open instead of flashing "No objects found" before the first load runs.

Kept the List (native selection, section headers, double-click to open, VoiceOver) and the sheet presentation. The bug was the height, not either of those.

Behavior

  • One result: panel is one row tall.
  • Content within the cap (~9 rows of items and headers): fits exactly, no blank space.
  • Beyond the cap: clamps and scrolls.
  • Empty query keeps its grouped sections, bounded by the same cap.

Tests

Eight unit tests on the view model: listHeight for zero items, one filtered row, at the cap, over the cap, the multi-section empty-query case, a Recent group adding a header (uncapped), the clamp engaging when sections and rows overflow; plus isLoading defaulting to true.

Verify on device

  • Row metrics (rowHeight 30, sectionHeaderHeight 28) are constants. List.inset adds a small outer content inset the arithmetic cannot see, so if there is a few-px gap or clipping, nudge those two constants.
  • The panel resizes once on open (loading to results) and as results filter. Confirm that motion reads cleanly; if it feels abrupt we can add a short height transition.

@datlechin datlechin merged commit 764e00a into main May 22, 2026
2 checks passed
@datlechin datlechin deleted the fix/quick-switcher-empty-space branch May 22, 2026 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Quick switcher has extra empty space below the list

1 participant