From de74639a6aa16cda716b5e18d94e212854d9aff4 Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Sat, 8 Aug 2020 22:48:14 -0700 Subject: [PATCH] fix: dont open links on home page --- src/components/NavigationItems.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/components/NavigationItems.js b/src/components/NavigationItems.js index ef53879b2..05bdf47b9 100644 --- a/src/components/NavigationItems.js +++ b/src/components/NavigationItems.js @@ -96,19 +96,17 @@ const NavIcon = ({ page }) => { const NavItem = ({ page, depthLevel, searchTerm, filteredPageNames }) => { const location = useLocation(); const crumbs = useContext(BreadcrumbContext).flatMap((x) => x.displayName); - const isHomepage = location.pathname === '/'; const isBreadCrumb = crumbs.includes(page.displayName); const matchesSearch = filteredPageNames?.includes(page.displayName); const hasChangedPage = location.pathname !== usePrevious(location.pathname); - const shouldExpand = (isHomepage && depthLevel === 0) || isBreadCrumb; - const [toggleIsExpanded, setToggleIsExpanded] = useState(shouldExpand); + const [toggleIsExpanded, setToggleIsExpanded] = useState(isBreadCrumb); const isExpanded = toggleIsExpanded || matchesSearch; useEffect(() => { if (hasChangedPage) { - setToggleIsExpanded(shouldExpand); + setToggleIsExpanded(isBreadCrumb); } - }, [hasChangedPage, shouldExpand]); + }, [hasChangedPage, isBreadCrumb]); const isCurrentPage = normalizeUrl(location.pathname) === normalizeUrl(page.url);