Skip to content

Commit 0bd1e59

Browse files
committed
hmm
1 parent dceefc6 commit 0bd1e59

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/lib/components/Accordion.svelte

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<script>
22
import IconChevron from '$lib/icons/icon-chevron.svg?raw';
33
import { onMount } from 'svelte';
4-
import { createEventDispatcher } from 'svelte';
54
65
export let id = (Math.random() * 10e15).toString(16);
76
export let type = "checkbox"; // or "radio"
@@ -10,14 +9,12 @@
109
export let foregroundColor = null;
1110
export let backgroundColor = null;
1211
13-
const dispatch = createEventDispatcher();
14-
1512
let contentEl, inputEl;
1613
onMount(() => {
1714
contentEl.style.display = inputEl.checked ? 'block' : 'none';
1815
});
1916
20-
function toggleContent() {
17+
function toggleContent(event) {
2118
if (inputEl.checked) {
2219
contentEl.style.display = 'block';
2320
contentEl.style.maxHeight = '0px';
@@ -30,8 +27,6 @@
3027
contentEl.style.maxHeight = '0px';
3128
});
3229
}
33-
// Dispatch click event so parent components can handle it (e.g., update URL hash)
34-
dispatch('click');
3530
}
3631
3732
function onTransitionEnd() {
@@ -49,7 +44,7 @@
4944
--background-color: {backgroundColor ?? (style === 'light' ? 'white' : 'black')};
5045
"
5146
>
52-
<input {type} name={id} {id} {checked} on:click={toggleContent} bind:this={inputEl} />
47+
<input {type} name={id} {id} {checked} on:click={toggleContent} on:click bind:this={inputEl} />
5348
<label for={id}>
5449
<slot name="label"></slot>
5550
<span class="chevron">{@html IconChevron}</span>

0 commit comments

Comments
 (0)