From 8677880b5779c84f2cd74b123a0d60b80d794482 Mon Sep 17 00:00:00 2001 From: eduarmreyes Date: Sun, 19 Mar 2023 17:14:19 -0700 Subject: [PATCH] fix navigation active issues --- src/components/About/Nav/index.js | 29 +++++++++++++--------------- src/components/LeftNav/menu-items.js | 4 ++-- src/components/Schedule/Nav/index.js | 13 +++++++------ src/constants.js | 2 +- 4 files changed, 23 insertions(+), 25 deletions(-) diff --git a/src/components/About/Nav/index.js b/src/components/About/Nav/index.js index 926103f3..2bd1fa9b 100644 --- a/src/components/About/Nav/index.js +++ b/src/components/About/Nav/index.js @@ -10,13 +10,10 @@ const AboutNav = ({ items, aboutPath }) => ( ...item, className: 'about-content-nav-item', activeLinkClassName: 'about-content-nav-item-is-active', - isActiveHandler: () => { - return ( - item.href === getLocationPathname() || - (getLocationPathname() === aboutPath && - item.href === '/about/topic-tables') - ) - }, + isActiveHandler: () => + item.href === getLocationPathname() || + (getLocationPathname() === aboutPath && + item.href === '/about/topic-tables/'), }))} /> @@ -26,34 +23,34 @@ AboutNav.defaultProps = { items: [ { text: 'Topic Tables', - href: '/about/topic-tables', + href: '/about/topic-tables/', }, { // text: 'Ask React Team', - // href: '/about/ask-react-team' + // href: '/about/ask-react-team/' // }, { // text: 'Unconference', - // href: '/about/unconference' + // href: '/about/unconference/' // }, { text: 'Venue and Hotel', - href: '/about/venue-and-hotel', + href: '/about/venue-and-hotel/', }, { text: 'Jobs', - href: '/about/jobs', + href: '/about/jobs/', // }, { // text: 'City Guide', - // href: '/about/city-guide' + // href: '/about/city-guide/' // }, { // text: 'Diversity & Safety', - // href: '/about#diversity-and-safety' + // href: '/about#diversity-and-safety/' }, { text: 'FAQ', - href: '/about/faq', + href: '/about/faq/', }, ], - aboutPath: '/about', + aboutPath: '/about/', } export default AboutNav diff --git a/src/components/LeftNav/menu-items.js b/src/components/LeftNav/menu-items.js index 6d59f547..b596cd7a 100644 --- a/src/components/LeftNav/menu-items.js +++ b/src/components/LeftNav/menu-items.js @@ -5,7 +5,7 @@ const menuItems = [ }, { name: 'About', - page: '/about', + page: '/about/', }, { name: 'Speakers', @@ -13,7 +13,7 @@ const menuItems = [ }, { name: 'Schedule', - page: '/schedule/day-1', + page: '/schedule/', }, { name: 'Workshops', diff --git a/src/components/Schedule/Nav/index.js b/src/components/Schedule/Nav/index.js index 5a8f6146..a29ec161 100644 --- a/src/components/Schedule/Nav/index.js +++ b/src/components/Schedule/Nav/index.js @@ -10,9 +10,10 @@ const ScheduleNav = ({ items }) => ( ...item, className: 'schedule-content-nav-item', activeLinkClassName: 'schedule-content-nav-item-is-active', - isActiveHandler: () => { - return item.href === `${getLocationPathname()}${getLocationHash()}` - }, + isActiveHandler: () => + (item.id === 'day1' && + `${getLocationPathname()}${getLocationHash()}` === '/schedule/') || + item.href === `${getLocationPathname()}${getLocationHash()}`, }))} showDivider={true} dividerClassName="schedule-content-nav-divider" @@ -25,17 +26,17 @@ ScheduleNav.defaultProps = { { id: 'day1', text: 'May 2', - href: '/schedule/day-1', + href: '/schedule/day-1/', }, { id: 'day2', text: 'May 3', - href: '/schedule/day-2', + href: '/schedule/day-2/', }, // { // id: 'day3', // text: 'May 4', - // href: '/schedule/day-3', + // href: '/schedule/day-3/', // }, ], } diff --git a/src/constants.js b/src/constants.js index 6c2f420a..e2d3209e 100644 --- a/src/constants.js +++ b/src/constants.js @@ -3,7 +3,7 @@ export const NATIVE_BREAKPOINT = '480' // 480px export const WIDE_BREAKPOINT = '799' // 799px; export const ROUTES = { home: '/', - about: '/about', + about: '/about/', speakers: '/speakers', workshops: '/workshops', schedule: '/schedule/day-1',