Skip to content

Commit

Permalink
fix(Select): allow on:change to be used
Browse files Browse the repository at this point in the history
  • Loading branch information
N00nDay committed Sep 25, 2023
1 parent 080fdcb commit 3f481a1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lib/components/select/Select.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,17 @@
$selectedValue = tempSelectedValues;
}
input.value = JSON.stringify($selectedValue);
input.dispatchEvent(new Event('change', { bubbles: true }));
value = $selectedValue;
} else {
if (value && !Array.isArray(value) && value[optionValue] === option[optionValue]) {
input.value = '';
input.dispatchEvent(new Event('change', { bubbles: true }));
value = undefined;
$selectedValue = undefined;
} else {
input.value = option[optionValue];
input.dispatchEvent(new Event('change', { bubbles: true }));
value = option;
$selectedValue = option;
}
Expand Down Expand Up @@ -157,6 +160,7 @@
{disabled}
bind:this={input}
bind:value={stringifyValues}
on:change
class="h-0 w-0 hidden invisible"
readonly
autocomplete="off"
Expand Down

0 comments on commit 3f481a1

Please sign in to comment.