diff --git a/src/components/CommandMenu/CommandMenu.tsx b/src/components/CommandMenu/CommandMenu.tsx index 822967dbb..f6ecf74fa 100644 --- a/src/components/CommandMenu/CommandMenu.tsx +++ b/src/components/CommandMenu/CommandMenu.tsx @@ -46,11 +46,13 @@ export function CommandMenu() { const normalizedSearchText = searchedText.trim().toLowerCase(); getAllPages().then((unfilteredPages = defaultPages) => { - const filteredPages = unfilteredPages.filter((currPage: PageType) => { - return ( - currPage.title.toLowerCase().indexOf(normalizedSearchText) !== -1 - ); - }); + const filteredPages = unfilteredPages + .filter((currPage: PageType) => { + return ( + currPage.title.toLowerCase().indexOf(normalizedSearchText) !== -1 + ); + }) + .slice(0, 10); setActiveCounter(0); setSearchResults(filteredPages); @@ -63,7 +65,7 @@ export function CommandMenu() { return (
-
+
- {searchResults.map((page, counter) => ( - setActiveCounter(counter)} - href={page.url} - > - {searchedText && ( - {page.group} - )} - {!searchedText && ( - ICON - )} - {page.title} - - ))} + {searchResults.length === 0 && ( +
+ No results found +
+ )} + + {searchResults.map((page, counter) => { + const prevPage = searchResults[counter - 1]; + const groupChanged = prevPage && prevPage.group !== page.group; + + return ( + <> + {groupChanged && ( +
+ )} + setActiveCounter(counter)} + href={page.url} + > + {searchedText && ( + {page.group} + )} + {!searchedText && ( + ICON + )} + {page.title} + + + ); + })}