diff --git a/packages/docs/src/components/layout/search/SearchModal.tsx b/packages/docs/src/components/layout/search/SearchModal.tsx index e227731b..32620ced 100644 --- a/packages/docs/src/components/layout/search/SearchModal.tsx +++ b/packages/docs/src/components/layout/search/SearchModal.tsx @@ -104,11 +104,11 @@ const SearchModal: FC = ({ open, onClose, searchablePages }) = setSearch(event.target.value); }, []); - const searchResults = useSearchScores(search, searchablePages); + const escapedSearch = useMemo(() => escapeRegExp(search), [search]); + + const searchResults = useSearchScores(escapedSearch, searchablePages); const renderedResults = useMemo(() => { - const escapedSearch = escapeRegExp(search); - return searchResults?.length > 0 ? ( [...Array(SEARCH_RESULTS_TO_SHOW)].map((_, index) => { if (searchResults.length <= index) { @@ -203,7 +203,7 @@ const SearchModal: FC = ({ open, onClose, searchablePages }) = ); - }, [handleClose, search, searchResults, theme.palette.primary.main]); + }, [escapedSearch, handleClose, searchResults, theme.palette.primary.main]); return (