GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(web): picker scrollbars match the list after you filter it (#43140) · patroza/t3code@7e629f3

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/web/src/components
    • DiffPanel.tsx
    • chat
      • ComposerCommandMenu.tsx
    • pullRequest
      • PullRequestCandidatePicker.tsx
    • settings
      • AddEnvironmentDialog.tsx
      • CloudVoiceConfiguration.tsx
      • ScheduledTasksSettings.tsx
    • ui
      • autocomplete.tsx
      • combobox.browser.test.tsx
      • combobox.tsx
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/web/src/components/DiffPanel.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/components/DiffPanel.tsx
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1318,7 +1318,7 @@ export default function DiffPanel({
13181318
<ComboboxEmpty>
13191319
<T>No matching refs.</T>
13201320
</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">
13221322
<ComboboxItem
13231323
className="w-full min-w-0 grid-cols-[1rem_minmax(0,1fr)]"
13241324
value={AUTOMATIC_BASE_REF}
Collapse file

‎apps/web/src/components/chat/ComposerCommandMenu.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/components/chat/ComposerCommandMenu.tsx
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ export const ComposerCommandMenu = memo(function ComposerCommandMenu(props: {
151151
aria-label={
152152
props.triggerKind ? m(LISTBOX_LABEL_BY_TRIGGER[props.triggerKind]) : undefined
153153
}
154-
className="max-h-72 min-h-0 scroll-pb-6"
154+
className="min-h-0 scroll-pb-6"
155+
scrollAreaClassName="max-h-72"
155156
>
156157
<CommandGroup>
157158
{props.items.map((item) => (
Collapse file

‎apps/web/src/components/pullRequest/PullRequestCandidatePicker.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/components/pullRequest/PullRequestCandidatePicker.tsx
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export function PullRequestCandidatePicker<T>({
107107
value={query}
108108
onChange={(event) => onQueryChange(event.target.value)}
109109
/>
110-
<ComboboxList className="max-h-72">
110+
<ComboboxList scrollAreaClassName="max-h-72">
111111
{isPending ? (
112112
<PullRequestPeopleGhost rows={4} />
113113
) : error !== null ? (
Collapse file

‎apps/web/src/components/settings/AddEnvironmentDialog.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/components/settings/AddEnvironmentDialog.tsx
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ export function AddEnvironmentDialog({
573573
<T>Loading hosts…</T>
574574
</div>
575575
) : filteredDiscoveredSshHosts.length > 0 ? (
576-
<AutocompleteList className="max-h-72">
576+
<AutocompleteList scrollAreaClassName="max-h-72">
577577
{filteredDiscoveredSshHosts.map((target, index) => {
578578
const address = formatDesktopSshTarget(target);
579579
const shortcutCommand = index < 9 ? threadJumpCommandForIndex(index) : null;
Collapse file

‎apps/web/src/components/settings/CloudVoiceConfiguration.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/components/settings/CloudVoiceConfiguration.tsx
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ function ModelPicker({
130130
<ComboboxEmpty>
131131
<T>No transcription model matches.</T>
132132
</ComboboxEmpty>
133-
<ComboboxList className="max-h-64">
133+
<ComboboxList scrollAreaClassName="max-h-64">
134134
{(model: CloudSpeechModel) => (
135135
<ComboboxItem key={model.id} value={model}>
136136
<span className="flex min-w-0 flex-col">
Collapse file

‎apps/web/src/components/settings/ScheduledTasksSettings.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/components/settings/ScheduledTasksSettings.tsx
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,7 @@ function ScheduledTaskDestination({
14621462
<ComboboxEmpty>
14631463
<T>No threads found.</T>
14641464
</ComboboxEmpty>
1465-
<ComboboxList className="max-h-72">
1465+
<ComboboxList scrollAreaClassName="max-h-72">
14661466
{items.map((value, index) => (
14671467
<ComboboxItem key={value} index={index} value={value}>
14681468
<span className="block truncate">
Collapse file

‎apps/web/src/components/ui/autocomplete.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/components/ui/autocomplete.tsx
+14-2Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,22 @@ function AutocompleteEmpty({ className, ...props }: AutocompletePrimitive.Empty.
191191
);
192192
}
193193

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+
}) {
195202
return (
196203
// 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+
>
198210
<AutocompletePrimitive.List
199211
className={cn("not-empty:scroll-py-1 not-empty:p-1", className)}
200212
data-slot="autocomplete-list"
Collapse file

‎apps/web/src/components/ui/combobox.browser.test.tsx‎

Copy file name to clipboard
+81Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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

‎apps/web/src/components/ui/combobox.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/components/ui/combobox.tsx
+9-2Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,16 @@ function ComboboxEmpty({ className, ...props }: ComboboxPrimitive.Empty.Props) {
229229
);
230230
}
231231

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+
}) {
233240
return (
234-
<ScrollArea scrollbarGutter scrollFade>
241+
<ScrollArea className={scrollAreaClassName} observeContent scrollbarGutter scrollFade>
235242
<ComboboxPrimitive.List
236243
className={cn("not-empty:scroll-py-1 not-empty:px-1 not-empty:py-1", className)}
237244
data-slot="combobox-list"

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.