fix(toolbar): fit quick switcher height to its results, cap at 9 rows (#1349)#1392
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
QuickSwitcherSheetpinned the whole panel to.frame(width: 460, height: 500). A SwiftUIListexpands 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
.frame(width:)only).QuickSwitcherViewModel.listHeight(rowHeight:headerHeight:maxVisibleRows:): it computes the natural content height (items + section headers) and clamps it to a single cap ofmaxVisibleRows * rowHeight(9 rows), then the list scrolls. Headers count toward the cap, so a dense empty-query view can never overshoot.isLoadingstartstrueso 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
Tests
Eight unit tests on the view model:
listHeightfor 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; plusisLoadingdefaulting to true.Verify on device
rowHeight30,sectionHeaderHeight28) are constants.List.insetadds a small outer content inset the arithmetic cannot see, so if there is a few-px gap or clipping, nudge those two constants.