Skip to content

Commit 6636e07

Browse files
committed
[fix](@svelteui/core): fix value reactivity prop in Accordion
1 parent 6cd35af commit 6636e07

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

packages/svelteui-core/src/components/Accordion/Accordion.stories.svelte

+8-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,14 @@
7575
</Story>
7676

7777
<Story name="Controlled" id="accordionControlledStory">
78-
<Accordion {value} on:change={(e) => (value = e.detail)}>
78+
<button
79+
on:click={() => {
80+
const array = ['typescript', 'packed', 'accessible'];
81+
value = array[Math.floor(Math.random() * array.length)];
82+
}}>Pick random</button
83+
>
84+
{value}
85+
<Accordion {value}>
7986
<Accordion.Item value="typescript">
8087
<div slot="control">Typescript Based</div>
8188
Build type safe applications. All SvelteUI packages are built with TypeScript and support it by

packages/svelteui-core/src/components/Accordion/Accordion.svelte

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
4141
const dispatch = createEventDispatcher();
4242
43-
let _value: AccordionValue<Multiple> = value || defaultValue;
43+
let _value: AccordionValue<Multiple>;
4444
let stateContent = {
4545
variant,
4646
order,
@@ -56,6 +56,7 @@
5656
const state = writable(stateContent);
5757
5858
// converts internal value into correct type
59+
$: _value = value || defaultValue;
5960
$: {
6061
if (multiple && !Array.isArray(_value)) {
6162
_value = (_value ? [_value] : []) as AccordionValue<Multiple>;

0 commit comments

Comments
 (0)