Skip to content

Commit 864feea

Browse files
authored
Fix active state in menu (#202)
1 parent 4fe1d5e commit 864feea

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/ds-svelte-community/src/routes/+layout.svelte

+6-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
}
2020
2121
let showSidebar = $state(false);
22+
23+
function compare(id: string | null, a: string) {
24+
const testID = a.replace(/\/+$/, "");
25+
return id === testID || (id == "/" && testID == "");
26+
}
2227
</script>
2328

2429
<Page background="bg-subtle">
@@ -52,7 +57,7 @@
5257
<!-- eslint-disable-next-line svelte/valid-compile using $ to access stores currently errors the validator -->
5358
<a
5459
class="unstyled"
55-
class:active={page.url.pathname == href}
60+
class:active={compare(page.route.id, href)}
5661
href={base + href}
5762
data-sveltekit-preload-data="tap"
5863
>

0 commit comments

Comments
 (0)