Skip to content

Commit

Permalink
[aksel.nav.no] Fix bug when clicking on active code example chip (#3303)
Browse files Browse the repository at this point in the history
  • Loading branch information
HalvorHaugan authored Oct 30, 2024
1 parent 3c53127 commit d7fb6b5
Showing 1 changed file with 20 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,25 +99,26 @@ const ComponentExamples = ({ node }: CodeExamplesProps) => {
{node.dir.filer.length > 1 && (
<div className="mb-5 max-w-xl">
<Chips>
{node.dir.filer.map((fil) => (
<Chips.Toggle
checkmark={false}
key={fil._key}
value={fil.navn}
selected={active === fil.navn}
id={`${node.dir.title.toLowerCase()}demo-${fil.navn}`}
onClick={async () => {
setUnloaded(true);
await router.replace(
`${
router.asPath.split("#")[0]
}#${node.dir.title.toLowerCase()}demo-${fil.navn}`,
);
}}
>
{fil.title}
</Chips.Toggle>
))}
{node.dir.filer.map((fil) => {
const id = `${node.dir.title.toLowerCase()}demo-${fil.navn}`;
return (
<Chips.Toggle
checkmark={false}
key={fil._key}
value={fil.navn}
selected={active === fil.navn}
id={id}
onClick={() => {
const newPath = `${router.asPath.split("#")[0]}#${id}`;
if (newPath === router.asPath) return;
setUnloaded(true);
router.replace(newPath);
}}
>
{fil.title}
</Chips.Toggle>
);
})}
</Chips>
</div>
)}
Expand Down

0 comments on commit d7fb6b5

Please sign in to comment.