2
0
mirror of https://github.com/tenrok/vue-select.git synced 2026-06-22 10:30:34 +03:00

never deselect options from the dropdown

This commit is contained in:
Jeff
2018-01-23 08:48:23 -08:00
parent 22d2004e2f
commit b3a551c836
2 changed files with 8 additions and 10 deletions
+4 -6
View File
@@ -759,9 +759,7 @@
* @return {void} * @return {void}
*/ */
select(option) { select(option) {
if (this.isOptionSelected(option)) { if (!this.isOptionSelected(option)) {
this.deselect(option)
} else {
if (this.taggable && !this.optionExists(option)) { if (this.taggable && !this.optionExists(option)) {
option = this.createOption(option) option = this.createOption(option)
} }
@@ -802,9 +800,9 @@
* Clears the currently selected value(s) * Clears the currently selected value(s)
* @return {void} * @return {void}
*/ */
clearSelection() { clearSelection() {
this.mutableValue = this.multiple ? [] : null this.mutableValue = this.multiple ? [] : null
}, },
/** /**
* Called from this.select after each selection. * Called from this.select after each selection.
+4 -4
View File
@@ -117,7 +117,7 @@ describe('Select.vue', () => {
options: [{label: 'This is Foo', value: 'foo'}, {label: 'This is Bar', value: 'bar'}] options: [{label: 'This is Foo', value: 'foo'}, {label: 'This is Bar', value: 'bar'}]
} }
}).$mount() }).$mount()
vm.$children[0].select({label: 'This is Foo', value: 'foo'}) vm.$children[0].deselect({label: 'This is Foo', value: 'foo'})
expect(vm.$children[0].mutableValue.length).toEqual(1) expect(vm.$children[0].mutableValue.length).toEqual(1)
}) })
@@ -129,7 +129,7 @@ describe('Select.vue', () => {
options: ['foo','bar'] options: ['foo','bar']
} }
}).$mount() }).$mount()
vm.$children[0].select('foo') vm.$children[0].deselect('foo')
expect(vm.$children[0].mutableValue.length).toEqual(1) expect(vm.$children[0].mutableValue.length).toEqual(1)
}), }),
@@ -1090,7 +1090,7 @@ describe('Select.vue', () => {
vm.$refs.select.search = 'one' vm.$refs.select.search = 'one'
searchSubmit(vm) searchSubmit(vm)
Vue.nextTick(() => { Vue.nextTick(() => {
expect(vm.$refs.select.mutableValue).toEqual([]) expect(vm.$refs.select.mutableValue).toEqual(['one'])
expect(vm.$refs.select.search).toEqual('') expect(vm.$refs.select.search).toEqual('')
done() done()
}) })
@@ -1109,7 +1109,7 @@ describe('Select.vue', () => {
vm.$refs.select.search = 'one' vm.$refs.select.search = 'one'
searchSubmit(vm) searchSubmit(vm)
Vue.nextTick(() => { Vue.nextTick(() => {
expect(vm.$refs.select.mutableValue).toEqual([]) expect(vm.$refs.select.mutableValue).toEqual(['one'])
expect(vm.$refs.select.search).toEqual('') expect(vm.$refs.select.search).toEqual('')
done() done()
}) })