diff --git a/aksel.nav.no/website/components/sanity-modules/code-examples/CodeExamples.tsx b/aksel.nav.no/website/components/sanity-modules/code-examples/CodeExamples.tsx index e67a21e10f..6082a72ec7 100644 --- a/aksel.nav.no/website/components/sanity-modules/code-examples/CodeExamples.tsx +++ b/aksel.nav.no/website/components/sanity-modules/code-examples/CodeExamples.tsx @@ -101,17 +101,18 @@ const ComponentExamples = ({ node }: CodeExamplesProps) => { {node.dir.filer.map((fil) => { const id = `${node.dir.title.toLowerCase()}demo-${fil.navn}`; + const isSelected = active === fil.navn; return ( { - const newPath = `${router.asPath.split("#")[0]}#${id}`; - if (newPath === router.asPath) return; + if (isSelected) return; setUnloaded(true); + const newPath = `${router.asPath.split("#")[0]}#${id}`; router.replace(newPath); }} >