Skip to content

Commit

Permalink
[fix](@svelteui/core): fix value reactivity prop in Accordion
Browse files Browse the repository at this point in the history
  • Loading branch information
BeeMargarida committed Apr 26, 2024
1 parent 6cd35af commit 6636e07
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,14 @@
</Story>

<Story name="Controlled" id="accordionControlledStory">
<Accordion {value} on:change={(e) => (value = e.detail)}>
<button
on:click={() => {
const array = ['typescript', 'packed', 'accessible'];
value = array[Math.floor(Math.random() * array.length)];
}}>Pick random</button
>
{value}
<Accordion {value}>
<Accordion.Item value="typescript">
<div slot="control">Typescript Based</div>
Build type safe applications. All SvelteUI packages are built with TypeScript and support it by
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
const dispatch = createEventDispatcher();
let _value: AccordionValue<Multiple> = value || defaultValue;
let _value: AccordionValue<Multiple>;
let stateContent = {
variant,
order,
Expand All @@ -56,6 +56,7 @@
const state = writable(stateContent);
// converts internal value into correct type
$: _value = value || defaultValue;
$: {
if (multiple && !Array.isArray(_value)) {
_value = (_value ? [_value] : []) as AccordionValue<Multiple>;
Expand Down

0 comments on commit 6636e07

Please sign in to comment.