TypeScript
refactor(web): reuse searchable picker inputs (#12353)
Julius Marminge8583eac643b8
diff --git a/apps/web/src/components/BranchToolbarBranchSelector.tsx b/apps/web/src/components/BranchToolbarBranchSelector.tsxindex db448990a4c..d958f2f7662 100644--- a/apps/web/src/components/BranchToolbarBranchSelector.tsx+++ b/apps/web/src/components/BranchToolbarBranchSelector.tsx@@ -9,7 +9,7 @@ import {} from "@t3tools/client-runtime/state/runtime";import type { ContextMenuItem, EnvironmentId, VcsRef, ThreadId } from "@t3tools/contracts";import { LegendList, type LegendListRef } from "@legendapp/list/react";-import { ChevronDownIcon, GitBranchIcon, SearchIcon } from "lucide-react";+import { ChevronDownIcon, GitBranchIcon } from "lucide-react";import {useCallback,useDeferredValue,@@ -64,7 +64,7 @@ import { getVirtualizedScrollFadeClassName } from "./ui/scroll-area";import {Combobox,ComboboxEmpty,- ComboboxInput,+ ComboboxSearchInput,ComboboxItem,ComboboxListVirtualized,ComboboxPopup,@@ -824,24 +824,11 @@ export function BranchToolbarBranchSelector({className="flex w-80 flex-col"{...composerFloatingLayerProps}>- <div className="shrink-0 px-3 pt-2.5">- <div className="relative -translate-y-px border-b border-border/70 pb-1.5 transition-colors focus-within:border-ring">- <SearchIcon- aria-hidden="true"- className="pointer-events-none absolute top-1.5 left-0 size-4 shrink-0 text-muted-foreground/55"- />- <ComboboxInput- className="[&_input]:h-6.5 [&_input]:ps-5 [&_input]:font-sans [&_input]:leading-6.5"- inputClassName="rounded-none bg-transparent text-sm"- placeholder="Search refs..."- showTrigger={false}- size="sm"- unstyled- value={branchQuery}- onChange={(event) => setBranchQuery(event.target.value)}- />- </div>- </div>+ <ComboboxSearchInput+ placeholder="Search refs..."+ value={branchQuery}+ onChange={(event) => setBranchQuery(event.target.value)}+ /><div className="flex min-h-0 flex-1 flex-col overflow-hidden"><ComboboxEmpty>No refs found.</ComboboxEmpty><div className="relative min-h-0 w-full max-h-56 flex-1 overflow-hidden">diff --git a/apps/web/src/components/DiffPanel.tsx b/apps/web/src/components/DiffPanel.tsxindex c1e52cfdaab..fd29acbff3f 100644--- a/apps/web/src/components/DiffPanel.tsx+++ b/apps/web/src/components/DiffPanel.tsx@@ -19,7 +19,6 @@ import {FolderTreeIcon,PilcrowIcon,Rows3Icon,- SearchIcon,TextWrapIcon,} from "lucide-react";import * as Schema from "effect/Schema";@@ -64,7 +63,7 @@ import { Switch } from "./ui/switch";import {Combobox,ComboboxEmpty,- ComboboxInput,+ ComboboxSearchInput,ComboboxItem,ComboboxList,ComboboxPopup,@@ -757,24 +756,11 @@ export default function DiffPanel({align="start"className="w-72 min-w-0 max-w-[calc(100vw-1rem)] overflow-hidden">- <div className="min-w-0 shrink-0 px-3 pt-2.5">- <div className="relative -translate-y-px border-b border-border/70 pb-1.5 transition-colors focus-within:border-ring">- <SearchIcon- aria-hidden="true"- className="pointer-events-none absolute top-1.5 left-0 size-4 shrink-0 text-muted-foreground/55"- />- <ComboboxInput- className="[&_input]:h-6.5 [&_input]:ps-5 [&_input]:font-sans [&_input]:leading-6.5"- inputClassName="rounded-none bg-transparent text-sm"- placeholder="Search refs..."- showTrigger={false}- size="sm"- unstyled- value={baseRefQuery}- onChange={(event) => setBaseRefQuery(event.target.value)}- />- </div>- </div>+ <ComboboxSearchInput+ placeholder="Search refs..."+ value={baseRefQuery}+ onChange={(event) => setBaseRefQuery(event.target.value)}+ /><div className="grid shrink-0 grid-cols-[1rem_minmax(0,1fr)] items-center gap-2 border-b border-border/70 ps-3 pe-6.5 pt-2 pb-1.5 font-medium text-[10px] text-muted-foreground uppercase tracking-wide"><span aria-hidden="true" /><div className="grid min-w-0 grid-cols-[minmax(0,1fr)_2rem] items-center">diff --git a/apps/web/src/components/pullRequest/PullRequestCandidatePicker.tsx b/apps/web/src/components/pullRequest/PullRequestCandidatePicker.tsxindex c8dd196f299..bae150dd918 100644--- a/apps/web/src/components/pullRequest/PullRequestCandidatePicker.tsx+++ b/apps/web/src/components/pullRequest/PullRequestCandidatePicker.tsx@@ -6,13 +6,12 @@* The same combobox as the project and branch pickers, and dressed the same, rather than a menu:* a menu's typeahead claims every keypress to jump between rows, which a search box cannot share.*/-import { SearchIcon } from "lucide-react";import type { ReactNode } from "react";import { Button } from "../ui/button";import {Combobox,- ComboboxInput,+ ComboboxSearchInput,ComboboxItem,ComboboxList,ComboboxPopup,@@ -123,25 +122,12 @@ export function PullRequestCandidatePicker<T>({}/><ComboboxPopup align="start" side="bottom" className="w-72">- <div className="shrink-0 px-3 pt-2.5">- <div className="relative -translate-y-px border-b border-border/70 pb-1.5 transition-colors focus-within:border-ring">- <SearchIcon- aria-hidden="true"- className="pointer-events-none absolute top-1.5 left-0 size-4 shrink-0 text-muted-foreground/55"- />- <ComboboxInput- aria-label={searchLabel}- className="[&_input]:h-6.5 [&_input]:ps-5 [&_input]:font-sans [&_input]:leading-6.5"- inputClassName="rounded-none bg-transparent text-sm"- placeholder={searchLabel}- showTrigger={false}- size="sm"- unstyled- value={query}- onChange={(event) => onQueryChange(event.target.value)}- />- </div>- </div>+ <ComboboxSearchInput+ aria-label={searchLabel}+ placeholder={searchLabel}+ value={query}+ onChange={(event) => onQueryChange(event.target.value)}+ /><ComboboxList className="max-h-72">{isPending ? (<PullRequestPeopleGhost rows={4} />diff --git a/apps/web/src/components/settings/FontFamilyPicker.tsx b/apps/web/src/components/settings/FontFamilyPicker.tsxindex 3fa5087e9da..4be5e43e566 100644--- a/apps/web/src/components/settings/FontFamilyPicker.tsx+++ b/apps/web/src/components/settings/FontFamilyPicker.tsx@@ -1,11 +1,11 @@import { LegendList, type LegendListRef } from "@legendapp/list/react";-import { CheckIcon, ChevronDownIcon, SearchIcon } from "lucide-react";+import { CheckIcon, ChevronDownIcon } from "lucide-react";import { useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";import { isMonospaceFamily, queryInstalledFontFamilies } from "../../appearanceFonts";import {Combobox,ComboboxEmpty,- ComboboxInput,+ ComboboxSearchInput,ComboboxItem,ComboboxListVirtualized,ComboboxPopup,@@ -211,24 +211,11 @@ export function FontFamilyPicker({<ChevronDownIcon className="-me-1 size-3 opacity-50" /></ComboboxTrigger><ComboboxPopup align="end" className="flex w-72 flex-col">- <div className="shrink-0 px-3 pt-2.5">- <div className="relative -translate-y-px border-b border-border/70 pb-1.5 transition-colors focus-within:border-ring">- <SearchIcon- aria-hidden="true"- className="pointer-events-none absolute top-1.5 left-0 size-4 shrink-0 text-muted-foreground/55"- />- <ComboboxInput- className="[&_input]:h-6.5 [&_input]:ps-5 [&_input]:font-sans [&_input]:leading-6.5"- inputClassName="rounded-none bg-transparent text-sm"- placeholder="Search fonts…"- showTrigger={false}- size="sm"- unstyled- value={query}- onChange={(event) => setQuery(event.target.value)}- />- </div>- </div>+ <ComboboxSearchInput+ placeholder="Search fonts…"+ value={query}+ onChange={(event) => setQuery(event.target.value)}+ /><div className="flex min-h-0 flex-1 flex-col overflow-hidden"><ComboboxEmpty>No fonts found.</ComboboxEmpty><div className="relative min-h-0 max-h-72 w-full flex-1 overflow-hidden">diff --git a/apps/web/src/components/ui/combobox.tsx b/apps/web/src/components/ui/combobox.tsxindex 6437f1fc872..863726f3241 100644--- a/apps/web/src/components/ui/combobox.tsx+++ b/apps/web/src/components/ui/combobox.tsx@@ -132,7 +132,7 @@ function ComboboxInput({function ComboboxSearchInput(props: React.ComponentProps<typeof ComboboxInput>) {return (- <div className="shrink-0 px-3 pt-2.5">+ <div className="min-w-0 shrink-0 px-3 pt-2.5"><div className="relative -translate-y-px border-b border-border/70 pb-1.5 transition-colors focus-within:border-ring"><SearchIconaria-hidden="true"