Skip to content

Commit

Permalink
fix(VCombobox): compare vs null/undefined as opposed to falsey in sel…
Browse files Browse the repository at this point in the history
…ectItem

fixes #8476
  • Loading branch information
johnleider committed Aug 31, 2019
1 parent db84347 commit f53cb81
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/vuetify/src/components/VCombobox/VCombobox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export default VAutocomplete.extend({
}
},
setValue (value?: any) {
VSelect.options.methods.setValue.call(this, value || this.internalSearch)
VSelect.options.methods.setValue.call(this, value != null ? value : this.internalSearch)

This comment has been minimized.

Copy link
@KaelWD
},
updateEditing () {
const value = this.internalValue.slice()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,4 +276,29 @@ describe('VCombobox.ts', () => {

expect(selectItem).toHaveBeenCalledWith('foo')
})

// https://github.com/vuetifyjs/vuetify/issues/8476
it('should properly compare falsey values when setting', async () => {
const wrapper = mountFunction()

wrapper.vm.setValue(0)
expect(wrapper.vm.internalValue).toBe(0)

wrapper.vm.setValue('')
expect(wrapper.vm.internalValue).toBe('')

wrapper.vm.setValue(null)
expect(wrapper.vm.internalValue).toBeUndefined()

wrapper.vm.setValue(undefined)
expect(wrapper.vm.internalValue).toBeUndefined()

wrapper.setData({ lazySearch: 'foo' })

wrapper.vm.setValue(null)
expect(wrapper.vm.internalValue).toBe('foo')

wrapper.vm.setValue(undefined)
expect(wrapper.vm.internalValue).toBe('foo')
})
})

0 comments on commit f53cb81

Please sign in to comment.