remain active on child pages of main section (#403)

fixing: #402
This commit is contained in:
Erik Jan de Wit 2021-03-01 22:12:57 +01:00 committed by GitHub
parent a48088765a
commit 72907d2583
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -44,12 +44,15 @@ export const PageNav: React.FunctionComponent = () => {
(route) => route.path.substr("/:realm".length) === path
);
if (!route || !hasAccess(route.access)) return <></>;
const activeItem = history.location.pathname;
//remove "/realm-name" from the start of the path
const activeItem = history.location.pathname.substr(realm.length + 1);
return (
<NavItem
id={"nav-item" + path.replace("/", "-")}
to={`/${realm}${path}`}
isActive={activeItem.substr(activeItem.indexOf("/", 1)) === path}
isActive={
path === activeItem || (path !== "/" && activeItem.startsWith(path))
}
>
{t(title)}
</NavItem>