fix(RadioButtonGroup): make selected prop reactive

This commit is contained in:
weaseldotro 2020-11-22 12:33:20 +02:00 committed by GitHub
commit 109f71b5cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -26,7 +26,7 @@
*/
export let id = undefined;
import { createEventDispatcher, setContext } from "svelte";
import { beforeUpdate, createEventDispatcher, onMount, setContext } from "svelte";
import { writable } from "svelte/store";
const dispatch = createEventDispatcher();
@ -44,7 +44,17 @@
},
});
$: selected = $selectedValue;
onMount(() => {
$selectedValue = selected
})
beforeUpdate(() => {
$selectedValue = selected
})
$: $selectedValue, (() => {
selected = $selectedValue
})
$: dispatch("change", $selectedValue);
</script>