diff --git a/packages/bbui/src/Form/Core/CheckboxGroup.svelte b/packages/bbui/src/Form/Core/CheckboxGroup.svelte
index 640d5d99cd..2b8a1e438a 100644
--- a/packages/bbui/src/Form/Core/CheckboxGroup.svelte
+++ b/packages/bbui/src/Form/Core/CheckboxGroup.svelte
@@ -12,23 +12,24 @@
export let getOptionValue = option => option
const dispatch = createEventDispatcher()
+
const onChange = e => {
- let tempValue = value
- let isChecked = e.target.checked
- if (!tempValue.includes(e.target.value) && isChecked) {
- tempValue.push(e.target.value)
+ const optionValue = e.target.value
+ if (e.target.checked && !value.includes(optionValue)) {
+ dispatch("change", [...value, optionValue])
+ } else {
+ dispatch(
+ "change",
+ value.filter(x => x !== optionValue)
+ )
}
- value = tempValue
- dispatch(
- "change",
- tempValue.filter(val => val !== e.target.value || isChecked)
- )
}
{#if options && Array.isArray(options)}
{#each options as option}
+ {@const optionValue = getOptionValue(option)}