Skip to content

Commit 3c4a8af

Browse files
fix(web): filter searches look like every other popup search
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 3c94236 commit 3c4a8af

2 files changed

Lines changed: 53 additions & 40 deletions

File tree

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

Lines changed: 11 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import {
3939
MenuRadioGroup,
4040
MenuRadioItem,
4141
MenuRadioItemIndicator,
42+
MenuSearchInput,
4243
MenuSeparator,
4344
MenuSub,
4445
MenuSubPopup,
@@ -262,39 +263,6 @@ function useHostedFilterOptions(
262263
return sent === typed ? hosted : { labels: [], authors: [], error: null, isPending: true };
263264
}
264265

265-
function PullRequestOptionSearch({
266-
label,
267-
busy,
268-
value,
269-
onChange,
270-
}: {
271-
label: string;
272-
busy: boolean;
273-
value: string;
274-
onChange: (value: string) => void;
275-
}) {
276-
return (
277-
<div className="p-1 pb-2">
278-
<InputGroup>
279-
<InputGroupAddon>
280-
{busy ? <Spinner aria-hidden /> : <SearchIcon aria-hidden />}
281-
</InputGroupAddon>
282-
<InputGroupInput
283-
autoFocus
284-
size="compact"
285-
value={value}
286-
onChange={(event) => onChange(event.currentTarget.value)}
287-
onKeyDown={(event) => {
288-
if (event.key !== "ArrowDown" && event.key !== "Escape") event.stopPropagation();
289-
}}
290-
placeholder={label}
291-
aria-label={label}
292-
/>
293-
</InputGroup>
294-
</div>
295-
);
296-
}
297-
298266
function PullRequestAuthorChoices({
299267
value,
300268
options,
@@ -319,11 +287,13 @@ function PullRequestAuthorChoices({
319287
const select = (next: string) => next.toLowerCase() !== login && onChange(next || undefined);
320288
return (
321289
<>
322-
<PullRequestOptionSearch
323-
label="Search authors"
290+
<MenuSearchInput
291+
autoFocus
324292
busy={hosted.isPending}
325293
value={query}
326-
onChange={setQuery}
294+
onChange={(event) => setQuery(event.currentTarget.value)}
295+
placeholder="Search authors"
296+
aria-label="Search authors"
327297
/>
328298
<MenuRadioGroup value={selected?.actor.login ?? value ?? ""} onValueChange={select}>
329299
<MenuRadioItem value="">
@@ -410,11 +380,13 @@ function PullRequestLabelChoices({
410380
];
411381
return (
412382
<>
413-
<PullRequestOptionSearch
414-
label="Search labels"
383+
<MenuSearchInput
384+
autoFocus
415385
busy={hosted.isPending}
416386
value={query}
417-
onChange={setQuery}
387+
onChange={(event) => setQuery(event.currentTarget.value)}
388+
placeholder="Search labels"
389+
aria-label="Search labels"
418390
/>
419391
{visible.length === 0 && !hosted.isPending ? (
420392
<MenuItem disabled>

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

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { Menu as MenuPrimitive } from "@base-ui/react/menu";
2-
import { CheckIcon, ChevronRightIcon } from "lucide-react";
2+
import { CheckIcon, ChevronRightIcon, SearchIcon } from "lucide-react";
33
import type * as React from "react";
44

55
import { cn } from "~/lib/utils";
66
import { buttonVariants } from "./button";
7+
import { Input, type InputProps } from "./input";
8+
import { Spinner } from "./spinner";
79

810
const Menu = MenuPrimitive.Root;
911

@@ -67,6 +69,44 @@ function MenuPopup({
6769
);
6870
}
6971

72+
/** A menu's filter field, drawn like `ComboboxSearchInput` so every searchable popup matches. */
73+
function MenuSearchInput({
74+
busy = false,
75+
onKeyDown,
76+
...props
77+
}: Omit<InputProps, "className" | "size" | "unstyled" | "nativeInput"> & { busy?: boolean }) {
78+
return (
79+
<div className="min-w-0 shrink-0 px-2 pt-1.5 pb-1">
80+
<div className="relative -translate-y-px border-b border-border/70 pb-1.5 transition-colors focus-within:border-ring">
81+
{busy ? (
82+
<Spinner
83+
aria-hidden="true"
84+
size="md"
85+
tone="muted"
86+
className="pointer-events-none absolute top-1.5 left-0"
87+
/>
88+
) : (
89+
<SearchIcon
90+
aria-hidden="true"
91+
className="pointer-events-none absolute top-1.5 left-0 size-4 shrink-0 text-muted-foreground/55"
92+
/>
93+
)}
94+
<Input
95+
{...props}
96+
className="rounded-none bg-transparent text-sm [&_input]:h-6.5 [&_input]:ps-5 [&_input]:font-sans [&_input]:leading-6.5"
97+
size="sm"
98+
unstyled
99+
onKeyDown={(event) => {
100+
// Menu typeahead would otherwise take the letters; arrows still reach the items.
101+
if (event.key !== "ArrowDown" && event.key !== "Escape") event.stopPropagation();
102+
onKeyDown?.(event);
103+
}}
104+
/>
105+
</div>
106+
</div>
107+
);
108+
}
109+
70110
function MenuGroup(props: MenuPrimitive.Group.Props) {
71111
return <MenuPrimitive.Group data-slot="menu-group" {...props} />;
72112
}
@@ -327,6 +367,7 @@ export {
327367
MenuTrigger as DropdownMenuTrigger,
328368
MenuPopup,
329369
MenuPopup as DropdownMenuContent,
370+
MenuSearchInput,
330371
MenuGroup,
331372
MenuGroup as DropdownMenuGroup,
332373
MenuItem,

0 commit comments

Comments
 (0)