mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 01:18:42 +00:00
Prevent full-page reloads when clicking some currently selected navbar links (#33500)
## For #31752 https://github.com/user-attachments/assets/3eaff439-b2be-4849-a1ae-b21fe8d67b97 - [x] Changes file added for user-visible changes in `changes/` - [x] QA'd all new/changed functionality manually --------- Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
This commit is contained in:
parent
82b9bc6b3e
commit
f9e53aa9a8
2 changed files with 9 additions and 11 deletions
1
changes/31752-clicking-active-nav-causes-page-rerender
Normal file
1
changes/31752-clicking-active-nav-causes-page-rerender
Normal file
|
|
@ -0,0 +1 @@
|
|||
- Fix a bug where clicking the currently selected navbar item would cause a full-page rerender
|
||||
|
|
@ -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 (
|
||||
<li className={navItemClasses} key={`nav-item-${name}`}>
|
||||
<a className={`${navItemBaseClass}__link`} href={includeTeamId(path)}>
|
||||
<Link to={path} className={`${navItemBaseClass}__link`}>
|
||||
<span
|
||||
className={`${navItemBaseClass}__name`}
|
||||
data-text={navItem.name}
|
||||
>
|
||||
{name}
|
||||
</span>
|
||||
</a>
|
||||
</Link>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue