Skip to content

Commit

Permalink
Merge pull request #5150 from nextcloud-libraries/fix/nc-checkbox
Browse files Browse the repository at this point in the history
fix(NcCheckboxRadioSwitch): Make sure to include current value in cheched array
  • Loading branch information
susnux authored Jan 26, 2024
2 parents 88ba309 + d6cd699 commit 61a191f
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -593,15 +593,20 @@ export default {

// If the initial value was a boolean, let's keep it that way
if (typeof this.checked === 'boolean') {
this.$emit('update:checked', !this.isChecked)
this.$emit('update:checked', !this.checked)
return
}

// Dispatch the checked values as an array if multiple, or single value otherwise
const values = this.getInputsSet()
.filter(input => input.checked)
.map(input => input.value)
this.$emit('update:checked', values)

if (values.includes(this.value)) {
this.$emit('update:checked', values.filter((v) => v !== this.value))
} else {
this.$emit('update:checked', [...values, this.value])
}
},

/**
Expand Down

0 comments on commit 61a191f

Please sign in to comment.