diff --git a/src/CommandMenu.tsx b/src/CommandMenu.tsx index 67fde61..b59e95e 100644 --- a/src/CommandMenu.tsx +++ b/src/CommandMenu.tsx @@ -189,16 +189,20 @@ const CommandMenu = ({metaData}: Props) => return B_FIRST; } - aStartsWith = labelA.toLowerCase().startsWith(searchString.toLowerCase()); - bStartsWith = labelB.toLowerCase().startsWith(searchString.toLowerCase()); + const indexOfSpace = searchString.indexOf(" "); + if (indexOfSpace > 0) + { + aStartsWith = labelA.toLowerCase().startsWith(searchString.substring(0, indexOfSpace).toLowerCase()); + bStartsWith = labelB.toLowerCase().startsWith(searchString.substring(0, indexOfSpace).toLowerCase()); - if (aStartsWith && !bStartsWith) - { - return A_FIRST; - } - else if (bStartsWith && !aStartsWith) - { - return B_FIRST; + if (aStartsWith && !bStartsWith) + { + return A_FIRST; + } + else if (bStartsWith && !aStartsWith) + { + return B_FIRST; + } } } @@ -439,7 +443,7 @@ const CommandMenu = ({metaData}: Props) => { - doFilter(value, search)}> + doFilter(value, search)}>