Skip to content

Commit

Permalink
fix: Handle navigation with no search term
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Jun 24, 2020
1 parent f46b7b7 commit 10d2ec1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/components/Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,14 @@ const filterPageNames = (pages, searchTerm, parent = []) => {
};

const Navigation = ({ className, searchTerm }) => {
const searchTermSanitized = searchTerm.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
const filteredPageNames =
searchTerm !== '' ? filterPageNames(pages, searchTermSanitized) : undefined;
const searchTermSanitized = searchTerm?.replace(
/[.*+?^${}()|[\]\\]/g,
'\\$&'
);

const filteredPageNames = searchTerm
? filterPageNames(pages, searchTermSanitized)
: undefined;

return (
<nav
Expand Down

0 comments on commit 10d2ec1

Please sign in to comment.