Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ui): sidebar plugin navitem doesn't get active when selected
Browse files Browse the repository at this point in the history
tadayosi committed Nov 27, 2023
1 parent 0546a6b commit ec0bcb8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/hawtio/src/ui/page/HawtioSidebar.tsx
Original file line number Diff line number Diff line change
@@ -7,11 +7,18 @@ export const HawtioSidebar: React.FunctionComponent = () => {
const { plugins } = useContext(PageContext)
const { pathname } = useLocation()

const pathMatch = (path: string, pluginPath: string) => {
if (!pluginPath.startsWith('/')) {
pluginPath = '/' + pluginPath
}
return path.startsWith(pluginPath)
}

const pageNav = (
<Nav theme='dark'>
<NavList>
{plugins.map(plugin => (
<NavItem key={plugin.id} isActive={plugin.path === pathname}>
<NavItem key={plugin.id} isActive={pathMatch(pathname, plugin.path)}>
<NavLink to={plugin.path}>{plugin.title}</NavLink>
</NavItem>
))}

0 comments on commit ec0bcb8

Please sign in to comment.