Skip to content

Commit b3a551c

Browse files
author
Jeff
committed
never deselect options from the dropdown
1 parent 22d2004 commit b3a551c

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/components/Select.vue

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -759,9 +759,7 @@
759759
* @return {void}
760760
*/
761761
select(option) {
762-
if (this.isOptionSelected(option)) {
763-
this.deselect(option)
764-
} else {
762+
if (!this.isOptionSelected(option)) {
765763
if (this.taggable && !this.optionExists(option)) {
766764
option = this.createOption(option)
767765
}
@@ -802,9 +800,9 @@
802800
* Clears the currently selected value(s)
803801
* @return {void}
804802
*/
805-
clearSelection() {
806-
this.mutableValue = this.multiple ? [] : null
807-
},
803+
clearSelection() {
804+
this.mutableValue = this.multiple ? [] : null
805+
},
808806
809807
/**
810808
* Called from this.select after each selection.

test/unit/specs/Select.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ describe('Select.vue', () => {
117117
options: [{label: 'This is Foo', value: 'foo'}, {label: 'This is Bar', value: 'bar'}]
118118
}
119119
}).$mount()
120-
vm.$children[0].select({label: 'This is Foo', value: 'foo'})
120+
vm.$children[0].deselect({label: 'This is Foo', value: 'foo'})
121121
expect(vm.$children[0].mutableValue.length).toEqual(1)
122122
})
123123

@@ -129,7 +129,7 @@ describe('Select.vue', () => {
129129
options: ['foo','bar']
130130
}
131131
}).$mount()
132-
vm.$children[0].select('foo')
132+
vm.$children[0].deselect('foo')
133133
expect(vm.$children[0].mutableValue.length).toEqual(1)
134134
}),
135135

@@ -1090,7 +1090,7 @@ describe('Select.vue', () => {
10901090
vm.$refs.select.search = 'one'
10911091
searchSubmit(vm)
10921092
Vue.nextTick(() => {
1093-
expect(vm.$refs.select.mutableValue).toEqual([])
1093+
expect(vm.$refs.select.mutableValue).toEqual(['one'])
10941094
expect(vm.$refs.select.search).toEqual('')
10951095
done()
10961096
})
@@ -1109,7 +1109,7 @@ describe('Select.vue', () => {
11091109
vm.$refs.select.search = 'one'
11101110
searchSubmit(vm)
11111111
Vue.nextTick(() => {
1112-
expect(vm.$refs.select.mutableValue).toEqual([])
1112+
expect(vm.$refs.select.mutableValue).toEqual(['one'])
11131113
expect(vm.$refs.select.search).toEqual('')
11141114
done()
11151115
})

0 commit comments

Comments
 (0)