Skip to content

Commit

Permalink
fix: Sidebar does not highlight demos
Browse files Browse the repository at this point in the history
This also fixes routing so as to preserve selected tab when switching between demos.

Signed-off-by: Nick Mitchell <[email protected]>
  • Loading branch information
starpit committed Jan 22, 2025
1 parent 4aee9d4 commit 1dd023a
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions pdl-live-react/src/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import demos from "./demos/demos"

export default function Sidebar() {
const { pathname: activeItem } = useLocation()
const { hash, pathname: activeItem } = useLocation()

return (
<PageSidebar id="pdl--vertical-sidebar">
Expand All @@ -26,18 +26,16 @@ export default function Sidebar() {
</NavItem>

<NavItem itemId="viewer" isActive={activeItem === "/upload"}>
<Link to="/upload">Upload a Trace</Link>
<Link to={"/upload" + hash}>Upload a Trace</Link>
</NavItem>
</NavList>

<NavGroup title="Demos">
{demos.map((demo) => {
const id = "/demos/" + demo.name
const id = "/demos/" + encodeURIComponent(demo.name)
return (
<NavItem key={id} itemId={id} isActive={activeItem === id}>
<Link to={`/demos/${encodeURIComponent(demo.name)}`}>
{demo.name}
</Link>
<Link to={id + hash}>{demo.name}</Link>
</NavItem>
)
})}
Expand Down

0 comments on commit 1dd023a

Please sign in to comment.