Skip to content

Commit

Permalink
fix(kselect): avoid incorrect event triggering with null (#2168)
Browse files Browse the repository at this point in the history
  • Loading branch information
Leopoldthecoder authored and adamdehaven committed Jun 3, 2024
1 parent 9f2ee5e commit f4079f0
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/components/KSelect/KSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,10 @@ const clearSelection = (): void => {
})
selectedItem.value = null
filterQuery.value = ''
// this 'input' event must be emitted for v-model binding to work properly
emit('input', null)
emit('change', null)
emit('update:modelValue', null)
}
const triggerFocus = (evt: any, isToggled: Ref<boolean>):void => {
Expand Down Expand Up @@ -655,19 +659,12 @@ watch(filterQuery, (q: string) => {
})
watch(selectedItem, (newVal, oldVal) => {
if (newVal) {
if (newVal !== oldVal) {
emit('selected', newVal)
// this 'input' event must be emitted for v-model binding to work properly
emit('input', newVal.value)
emit('change', newVal)
emit('update:modelValue', newVal.value)
}
} else {
if (newVal && newVal !== oldVal) {
emit('selected', newVal)
// this 'input' event must be emitted for v-model binding to work properly
emit('input', null)
emit('change', null)
emit('update:modelValue', null)
emit('input', newVal.value)
emit('change', newVal)
emit('update:modelValue', newVal.value)
}
}, { deep: true })
Expand Down

0 comments on commit f4079f0

Please sign in to comment.