diff --git a/changes/31752-clicking-active-nav-causes-page-rerender b/changes/31752-clicking-active-nav-causes-page-rerender new file mode 100644 index 0000000000..5bb8b71c40 --- /dev/null +++ b/changes/31752-clicking-active-nav-causes-page-rerender @@ -0,0 +1 @@ +- Fix a bug where clicking the currently selected navbar item would cause a full-page rerender diff --git a/frontend/components/top_nav/SiteTopNav/SiteTopNav.tsx b/frontend/components/top_nav/SiteTopNav/SiteTopNav.tsx index 60b0a8d3b6..727da40f34 100644 --- a/frontend/components/top_nav/SiteTopNav/SiteTopNav.tsx +++ b/frontend/components/top_nav/SiteTopNav/SiteTopNav.tsx @@ -164,18 +164,15 @@ const SiteTopNav = ({ } if (active && !isActiveDetailPage) { - const path = navItem.alwaysToPathname + let path = navItem.alwaysToPathname ? navItem.location.pathname : currentPath; - const includeTeamId = (activePath: string) => { - if (currentQueryParams.team_id !== API_ALL_TEAMS_ID) { - return getPathWithQueryParams(path, { - team_id: currentQueryParams.team_id, - }); - } - return activePath; - }; + if (currentQueryParams.team_id !== API_ALL_TEAMS_ID) { + path = getPathWithQueryParams(path, { + team_id: currentQueryParams.team_id, + }); + } // Clicking an active link returns user to default page // Resetting all filters except team ID @@ -183,14 +180,14 @@ const SiteTopNav = ({ // replace to the same url, which triggers a re-render) return (
  • - + {name} - +
  • ); }