diff --git a/packages/cli/src/components/SearchBox.tsx b/packages/cli/src/components/SearchBox.tsx index 872778e..de86ff1 100644 --- a/packages/cli/src/components/SearchBox.tsx +++ b/packages/cli/src/components/SearchBox.tsx @@ -17,7 +17,7 @@ export function SearchBox({ initialQuery?: string onKeyDown?: (i: string, k: Key, app: ReturnType) => void onChange?: (item: T) => void - onSubmit?: (value: string) => void + onSubmit?: (item: T) => void }) { const [query, setQuery] = useState(initialQuery ?? '') const [queryMode, setQueryMode] = useState(true) @@ -79,7 +79,10 @@ export function SearchBox({ }} showCursor placeholder={' query'} - onSubmit={onSubmit} + onSubmit={() => { + const found = components.find(({key}) => key === suggestions[selected]) + found && onSubmit?.(found) + }} />