diff --git a/packages/switch/src/lib/switch.svelte b/packages/switch/src/lib/switch.svelte index 8584c48..5a9b79a 100644 --- a/packages/switch/src/lib/switch.svelte +++ b/packages/switch/src/lib/switch.svelte @@ -60,8 +60,14 @@ } } - if (actualValue !== activeValue && actualValue !== inactiveValue) { + if ( + (value === undefined || value === null) && + actualValue !== activeValue && + actualValue !== inactiveValue + ) { + console.log('11', value); value = inactiveValue; + console.log('222', value); dispatch('change', value); dispatch('input', value); } @@ -69,8 +75,10 @@ let input; function handleChange() { + console.log('333', value); const val = checked ? inactiveValue : activeValue; value = val; + console.log('444', value); dispatch('change', val); dispatch('input', val); tick().then(() => { @@ -131,7 +139,7 @@ {/if}
{#if loading} - + {:else if activeActionIcon && checked} diff --git a/packages/switch/src/routes/+page.svelte b/packages/switch/src/routes/+page.svelte index 7b877c9..59db75e 100644 --- a/packages/switch/src/routes/+page.svelte +++ b/packages/switch/src/routes/+page.svelte @@ -7,34 +7,38 @@ {value} - + - + -
+ - - + + - -
- - -
- -
- + + + + + + + + -
- - - - + + + + + + + + + + - - - - + +
- + +