Skip to content

Commit

Permalink
fix: allow selecting boolean values (#1518)
Browse files Browse the repository at this point in the history
  • Loading branch information
sagalbot authored Feb 18, 2022
1 parent f8a41df commit a1944e0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/Select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ export default {
value = this.$data._value
}
if (value) {
if (value !== undefined && value !== null) {
return [].concat(value)
}
Expand Down
17 changes: 17 additions & 0 deletions tests/unit/Selecting.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,23 @@ describe('VS - Selecting Values', () => {
expect(Select.vm.selectedValue).toEqual(options)
})

fit('can select a false boolean option', async () => {
const Select = mountDefault({
options: [false],
})

expect(Select.vm.isOptionSelected(false)).toBeFalsy()
expect(Select.vm.optionExists(false)).toBeTruthy()

Select.vm.open = true
await Select.vm.$nextTick()

Select.find('.vs__dropdown-option').trigger('click')
await Select.vm.$nextTick()

expect(Select.vm.selectedValue).toEqual([false])
})

describe('input Event', () => {
it('will trigger the input event when the selection changes', () => {
const Select = shallowMount(VueSelect)
Expand Down

0 comments on commit a1944e0

Please sign in to comment.