GeezerVison is showing github.com — fix(web): picker scrollbars match the list after you filter it (#43140) · patroza/t3code@7e629f3
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/web/src/components/DiffPanel.tsx +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -1318,7 +1318,7 @@ export default function DiffPanel({ | 1318 | 1318 | <ComboboxEmpty> | 1319 | 1319 | <T>No matching refs.</T> | 1320 | 1320 | </ComboboxEmpty> | 1321 | | - <ComboboxList className="max-h-64 min-w-0 overflow-x-hidden"> | | 1321 | + <ComboboxList className="min-w-0 overflow-x-hidden" scrollAreaClassName="max-h-64"> | 1322 | 1322 | <ComboboxItem | 1323 | 1323 | className="w-full min-w-0 grid-cols-[1rem_minmax(0,1fr)]" | 1324 | 1324 | value={AUTOMATIC_BASE_REF} | |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/components/chat/ComposerCommandMenu.tsx +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -151,7 +151,8 @@ export const ComposerCommandMenu = memo(function ComposerCommandMenu(props: { | 151 | 151 | aria-label={ | 152 | 152 | props.triggerKind ? m(LISTBOX_LABEL_BY_TRIGGER[props.triggerKind]) : undefined | 153 | 153 | } | 154 | | - className="max-h-72 min-h-0 scroll-pb-6" | | 154 | + className="min-h-0 scroll-pb-6" | | 155 | + scrollAreaClassName="max-h-72" | 155 | 156 | > | 156 | 157 | <CommandGroup> | 157 | 158 | {props.items.map((item) => ( | |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/components/pullRequest/PullRequestCandidatePicker.tsx +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -107,7 +107,7 @@ export function PullRequestCandidatePicker<T>({ | 107 | 107 | value={query} | 108 | 108 | onChange={(event) => onQueryChange(event.target.value)} | 109 | 109 | /> | 110 | | - <ComboboxList className="max-h-72"> | | 110 | + <ComboboxList scrollAreaClassName="max-h-72"> | 111 | 111 | {isPending ? ( | 112 | 112 | <PullRequestPeopleGhost rows={4} /> | 113 | 113 | ) : error !== null ? ( | |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/components/settings/AddEnvironmentDialog.tsx +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -573,7 +573,7 @@ export function AddEnvironmentDialog({ | 573 | 573 | <T>Loading hosts…</T> | 574 | 574 | </div> | 575 | 575 | ) : filteredDiscoveredSshHosts.length > 0 ? ( | 576 | | - <AutocompleteList className="max-h-72"> | | 576 | + <AutocompleteList scrollAreaClassName="max-h-72"> | 577 | 577 | {filteredDiscoveredSshHosts.map((target, index) => { | 578 | 578 | const address = formatDesktopSshTarget(target); | 579 | 579 | const shortcutCommand = index < 9 ? threadJumpCommandForIndex(index) : null; | |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/components/settings/CloudVoiceConfiguration.tsx +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -130,7 +130,7 @@ function ModelPicker({ | 130 | 130 | <ComboboxEmpty> | 131 | 131 | <T>No transcription model matches.</T> | 132 | 132 | </ComboboxEmpty> | 133 | | - <ComboboxList className="max-h-64"> | | 133 | + <ComboboxList scrollAreaClassName="max-h-64"> | 134 | 134 | {(model: CloudSpeechModel) => ( | 135 | 135 | <ComboboxItem key={model.id} value={model}> | 136 | 136 | <span className="flex min-w-0 flex-col"> | |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/components/settings/ScheduledTasksSettings.tsx +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -1462,7 +1462,7 @@ function ScheduledTaskDestination({ | 1462 | 1462 | <ComboboxEmpty> | 1463 | 1463 | <T>No threads found.</T> | 1464 | 1464 | </ComboboxEmpty> | 1465 | | - <ComboboxList className="max-h-72"> | | 1465 | + <ComboboxList scrollAreaClassName="max-h-72"> | 1466 | 1466 | {items.map((value, index) => ( | 1467 | 1467 | <ComboboxItem key={value} index={index} value={value}> | 1468 | 1468 | <span className="block truncate"> | |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/components/ui/autocomplete.tsx +14-2Lines changed: 14 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -191,10 +191,22 @@ function AutocompleteEmpty({ className, ...props }: AutocompletePrimitive.Empty. | 191 | 191 | ); | 192 | 192 | } | 193 | 193 |
| 194 | | -function AutocompleteList({ className, ...props }: AutocompletePrimitive.List.Props) { | | 194 | +function AutocompleteList({ | | 195 | + className, | | 196 | + scrollAreaClassName, | | 197 | + ...props | | 198 | +}: AutocompletePrimitive.List.Props & { | | 199 | + /** Put height caps here, not on `className`: a capped list never resizes, so the scrollbar goes stale. */ | | 200 | + scrollAreaClassName?: string; | | 201 | +}) { | 195 | 202 | return ( | 196 | 203 | // A flex column lets the viewport shrink with a height-capped parent instead of overflowing it. | 197 | | - <ScrollArea className="flex flex-col" scrollbarGutter scrollFade> | | 204 | + <ScrollArea | | 205 | + className={cn("flex flex-col", scrollAreaClassName)} | | 206 | + observeContent | | 207 | + scrollbarGutter | | 208 | + scrollFade | | 209 | + > | 198 | 210 | <AutocompletePrimitive.List | 199 | 211 | className={cn("not-empty:scroll-py-1 not-empty:p-1", className)} | 200 | 212 | data-slot="autocomplete-list" | |
Collapse file Copy file name to clipboard +81Lines changed: 81 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +import { expect, it, vi } from "vite-plus/test"; | | 2 | +import { page, userEvent } from "vite-plus/test/browser"; | | 3 | + | | 4 | +import "~/index.css"; | | 5 | + | | 6 | +import { render } from "../../../test/render"; | | 7 | +import { | | 8 | + Autocomplete, | | 9 | + AutocompleteInput, | | 10 | + AutocompleteItem, | | 11 | + AutocompleteList, | | 12 | + AutocompletePopup, | | 13 | +} from "./autocomplete"; | | 14 | +import { Combobox, ComboboxInput, ComboboxItem, ComboboxList, ComboboxPopup } from "./combobox"; | | 15 | + | | 16 | +const items = [ | | 17 | + ...Array.from({ length: 40 }, (_, index) => `option-${index}`), | | 18 | + ...Array.from({ length: 12 }, (_, index) => `match-${index}`), | | 19 | +]; | | 20 | + | | 21 | +const pickers = { | | 22 | + combobox: ( | | 23 | + <Combobox defaultOpen items={items}> | | 24 | + <ComboboxInput aria-label="Search options" /> | | 25 | + <ComboboxPopup> | | 26 | + <ComboboxList scrollAreaClassName="max-h-72"> | | 27 | + {(item: string) => ( | | 28 | + <ComboboxItem key={item} value={item}> | | 29 | + {item} | | 30 | + </ComboboxItem> | | 31 | + )} | | 32 | + </ComboboxList> | | 33 | + </ComboboxPopup> | | 34 | + </Combobox> | | 35 | + ), | | 36 | + autocomplete: ( | | 37 | + <Autocomplete defaultOpen items={items}> | | 38 | + <AutocompleteInput aria-label="Search options" /> | | 39 | + <AutocompletePopup> | | 40 | + <AutocompleteList scrollAreaClassName="max-h-72"> | | 41 | + {(item: string) => ( | | 42 | + <AutocompleteItem key={item} value={item}> | | 43 | + {item} | | 44 | + </AutocompleteItem> | | 45 | + )} | | 46 | + </AutocompleteList> | | 47 | + </AutocompletePopup> | | 48 | + </Autocomplete> | | 49 | + ), | | 50 | +}; | | 51 | + | | 52 | +it.each(["combobox", "autocomplete"] as const)( | | 53 | + "resizes the capped %s scrollbar thumb when filtering shortens the list", | | 54 | + async (kind) => { | | 55 | + await using _screen = await render(pickers[kind], { | | 56 | + router: false /* filtering a popup list does not involve routing */, | | 57 | + }); | | 58 | + | | 59 | + const viewport = page | | 60 | + .getByRole("listbox") | | 61 | + .element() | | 62 | + .closest("[data-slot=scroll-area-viewport]"); | | 63 | + if (!viewport) throw new Error("List is not inside a scroll area"); | | 64 | + await vi.waitFor(() => expect(viewport.clientHeight).toBeLessThanOrEqual(288)); | | 65 | + const thumbHeight = () => | | 66 | + document | | 67 | + .querySelector( | | 68 | + "[data-slot=scroll-area-scrollbar][data-orientation=vertical] [data-slot=scroll-area-thumb]", | | 69 | + ) | | 70 | + ?.getBoundingClientRect().height ?? 0; | | 71 | + await vi.waitFor(() => expect(thumbHeight()).toBeGreaterThan(0)); | | 72 | + const unfilteredThumbHeight = thumbHeight(); | | 73 | + | | 74 | + await userEvent.click(page.getByRole("combobox", { name: "Search options" })); | | 75 | + await userEvent.keyboard("match"); | | 76 | + await vi.waitFor(() => expect(page.getByRole("option").elements()).toHaveLength(12)); | | 77 | + await vi.waitFor(() => expect(viewport.scrollHeight).toBeGreaterThan(viewport.clientHeight)); | | 78 | + | | 79 | + await vi.waitFor(() => expect(thumbHeight()).toBeGreaterThan(unfilteredThumbHeight * 2)); | | 80 | + }, | | 81 | +); |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/components/ui/combobox.tsx +9-2Lines changed: 9 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -229,9 +229,16 @@ function ComboboxEmpty({ className, ...props }: ComboboxPrimitive.Empty.Props) { | 229 | 229 | ); | 230 | 230 | } | 231 | 231 |
| 232 | | -function ComboboxList({ className, ...props }: ComboboxPrimitive.List.Props) { | | 232 | +function ComboboxList({ | | 233 | + className, | | 234 | + scrollAreaClassName, | | 235 | + ...props | | 236 | +}: ComboboxPrimitive.List.Props & { | | 237 | + /** Put height caps here, not on `className`: a capped list never resizes, so the scrollbar goes stale. */ | | 238 | + scrollAreaClassName?: string; | | 239 | +}) { | 233 | 240 | return ( | 234 | | - <ScrollArea scrollbarGutter scrollFade> | | 241 | + <ScrollArea className={scrollAreaClassName} observeContent scrollbarGutter scrollFade> | 235 | 242 | <ComboboxPrimitive.List | 236 | 243 | className={cn("not-empty:scroll-py-1 not-empty:px-1 not-empty:py-1", className)} | 237 | 244 | data-slot="combobox-list" | |
|