From 3a09752322e077be1753cada10981d28474a5156 Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Fri, 7 Jun 2024 22:52:23 -0700 Subject: [PATCH] Fix cmd+k filtering --- src-web/components/CommandPalette.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src-web/components/CommandPalette.tsx b/src-web/components/CommandPalette.tsx index e3575f61..288906cb 100644 --- a/src-web/components/CommandPalette.tsx +++ b/src-web/components/CommandPalette.tsx @@ -28,6 +28,8 @@ type CommandPaletteItem = { onSelect: () => void; } & ({ searchText: string; label: ReactNode } | { label: string }); +const MAX_PER_GROUP = 4; + export function CommandPalette({ onClose }: { onClose: () => void }) { const [selectedItemKey, setSelectedItemKey] = useState(null); const routes = useAppRoutes(); @@ -82,7 +84,7 @@ export function CommandPalette({ onClose }: { onClose: () => void }) { items: [], }; - for (const r of sortedRequests.slice(0, 4)) { + for (const r of sortedRequests) { if (r.id === activeRequestId) { continue; } @@ -112,7 +114,7 @@ export function CommandPalette({ onClose }: { onClose: () => void }) { items: [], }; - for (const w of sortedWorkspaces.slice(0, 4)) { + for (const w of sortedWorkspaces) { if (w.id === activeWorkspaceId) { continue; } @@ -200,7 +202,7 @@ export function CommandPalette({ onClose }: { onClose: () => void }) { label="Command" placeholder="Search or type a command" className="font-sans !text-base" - defaultValue="" + defaultValue={command} onChange={setCommand} onKeyDownCapture={handleKeyDown} /> @@ -211,7 +213,7 @@ export function CommandPalette({ onClose }: { onClose: () => void }) { {g.label} - {g.items.map((v) => ( + {g.items.slice(0, MAX_PER_GROUP).map((v) => (