From 10d2ec1b7eb6b3f83efe8a65d4a68f9b4e046e1c Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Wed, 24 Jun 2020 12:21:54 -0700 Subject: [PATCH] fix: Handle navigation with no search term --- src/components/Navigation.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/Navigation.js b/src/components/Navigation.js index bf5f31a12..0c1c63fec 100644 --- a/src/components/Navigation.js +++ b/src/components/Navigation.js @@ -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 (