docs: fix search regex escaping
This commit is contained in:
parent
27b6112cba
commit
f90f805a24
@ -104,11 +104,11 @@ const SearchModal: FC<SearchModalProps> = ({ open, onClose, searchablePages }) =
|
|||||||
setSearch(event.target.value);
|
setSearch(event.target.value);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const searchResults = useSearchScores(search, searchablePages);
|
const escapedSearch = useMemo(() => escapeRegExp(search), [search]);
|
||||||
|
|
||||||
|
const searchResults = useSearchScores(escapedSearch, searchablePages);
|
||||||
|
|
||||||
const renderedResults = useMemo(() => {
|
const renderedResults = useMemo(() => {
|
||||||
const escapedSearch = escapeRegExp(search);
|
|
||||||
|
|
||||||
return searchResults?.length > 0 ? (
|
return searchResults?.length > 0 ? (
|
||||||
[...Array<unknown>(SEARCH_RESULTS_TO_SHOW)].map((_, index) => {
|
[...Array<unknown>(SEARCH_RESULTS_TO_SHOW)].map((_, index) => {
|
||||||
if (searchResults.length <= index) {
|
if (searchResults.length <= index) {
|
||||||
@ -203,7 +203,7 @@ const SearchModal: FC<SearchModalProps> = ({ open, onClose, searchablePages }) =
|
|||||||
</StyledSuggestionSection>
|
</StyledSuggestionSection>
|
||||||
</StyledSuggestions>
|
</StyledSuggestions>
|
||||||
);
|
);
|
||||||
}, [handleClose, search, searchResults, theme.palette.primary.main]);
|
}, [escapedSearch, handleClose, searchResults, theme.palette.primary.main]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledDialog open={open} onClose={handleClose} fullScreen={fullScreen} fullWidth>
|
<StyledDialog open={open} onClose={handleClose} fullScreen={fullScreen} fullWidth>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user