Emit Checkbox change event after modifying internal state (#1013)

The checkbox's internal state doesn't match the visual checked /
unchecked state. The behaviour is visible when using 1-way binding on
the checkbox and using the on:change event. The internal state is always
the opposite of the visual state.
This commit is contained in:
Alexis Reigel 2022-01-17 21:50:08 +01:00 committed by GitHub
commit 9b32fe90f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -89,13 +89,13 @@
name="{name}" name="{name}"
readonly="{readonly}" readonly="{readonly}"
class:bx--checkbox="{true}" class:bx--checkbox="{true}"
on:change
on:change="{() => { on:change="{() => {
checked = !checked; checked = !checked;
group = group.includes(value) group = group.includes(value)
? group.filter((_value) => _value !== value) ? group.filter((_value) => _value !== value)
: [...group, value]; : [...group, value];
}}" }}"
on:change
on:blur on:blur
/> />
<label for="{id}" title="{title}" class:bx--checkbox-label="{true}"> <label for="{id}" title="{title}" class:bx--checkbox-label="{true}">