docs: fix search regex escaping

This commit is contained in:
Daniel Lautzenheiser 2023-11-08 15:34:05 -05:00
parent 27b6112cba
commit f90f805a24

View File

@ -104,11 +104,11 @@ const SearchModal: FC<SearchModalProps> = ({ 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<unknown>(SEARCH_RESULTS_TO_SHOW)].map((_, index) => {
if (searchResults.length <= index) {
@ -203,7 +203,7 @@ const SearchModal: FC<SearchModalProps> = ({ open, onClose, searchablePages }) =
</StyledSuggestionSection>
</StyledSuggestions>
);
}, [handleClose, search, searchResults, theme.palette.primary.main]);
}, [escapedSearch, handleClose, searchResults, theme.palette.primary.main]);
return (
<StyledDialog open={open} onClose={handleClose} fullScreen={fullScreen} fullWidth>