diff --git a/cmdk/src/index.tsx b/cmdk/src/index.tsx index 86a55a2..04bba83 100644 --- a/cmdk/src/index.tsx +++ b/cmdk/src/index.tsx @@ -358,7 +358,9 @@ const Command = React.forwardRef((props, forwarded function score(value: string, keywords?: string[]) { const filter = propsRef.current?.filter ?? defaultFilter - return value ? filter(value, state.current.search, keywords) : 0 + const search = state.current.search ?? '' + const sanitizedSearch = search.replace(/\s+/g, ' ').trim() + return value ? filter(value, sanitizedSearch, keywords) : 0 } /** Sorts items by score, and groups by highest item score. */