mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-19 09:50:33 +03:00
improving name for should-dropdown-close option. adding test
This commit is contained in:
@@ -34,7 +34,8 @@
|
|||||||
<v-select placeholder="multiple" multiple :options="options"></v-select>
|
<v-select placeholder="multiple" multiple :options="options"></v-select>
|
||||||
<v-select placeholder="multiple, taggable" multiple taggable :options="options" no-drop></v-select>
|
<v-select placeholder="multiple, taggable" multiple taggable :options="options" no-drop></v-select>
|
||||||
<v-select placeholder="multiple, taggable, push-tags" multiple push-tags taggable :options="[{label: 'Foo', value: 'foo'}]"></v-select>
|
<v-select placeholder="multiple, taggable, push-tags" multiple push-tags taggable :options="[{label: 'Foo', value: 'foo'}]"></v-select>
|
||||||
<v-select placeholder="multiple, closeOnSelect" multiple :close-on-multi-select="true" :options="['cat', 'dog', 'bear']"></v-select>
|
<v-select placeholder="multiple, closeOnSelect=true" multiple :options="['cat', 'dog', 'bear']"></v-select>
|
||||||
|
<v-select placeholder="multiple, closeOnSelect=false" multiple :close-on-select="false" :options="['cat', 'dog', 'bear']"></v-select>
|
||||||
<v-select placeholder="unsearchable" :options="options" :searchable="false"></v-select>
|
<v-select placeholder="unsearchable" :options="options" :searchable="false"></v-select>
|
||||||
<v-select placeholder="search github.." label="full_name" @search="search" :options="ajaxRes"></v-select>
|
<v-select placeholder="search github.." label="full_name" @search="search" :options="ajaxRes"></v-select>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -391,13 +391,13 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows user to choose to close the select dropdown when an option is selected.
|
* Close a dropdown when an option is select. Set to false to keep the dropdown
|
||||||
* set to true when multiple=true to close the dropdown between each selection
|
* open (useful when combined with multi-select, for example)
|
||||||
* @type {Boolean}
|
* @type {Boolean}
|
||||||
*/
|
*/
|
||||||
closeOnMultiSelect: {
|
closeOnSelect: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: true
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -635,12 +635,7 @@
|
|||||||
* @return {void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
onAfterSelect(option) {
|
onAfterSelect(option) {
|
||||||
if (this.multiple) {
|
if (this.closeOnSelect) {
|
||||||
if (this.closeOnMultiSelect) {
|
|
||||||
this.open = !this.open
|
|
||||||
this.$refs.search.blur()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.open = !this.open
|
this.open = !this.open
|
||||||
this.$refs.search.blur()
|
this.$refs.search.blur()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -351,9 +351,10 @@ describe('Select.vue', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can close the dropdown when the el is clicked, multiple is true, and multipleCloseOnSelect option is true', (done) => {
|
|
||||||
|
it('closes the dropdown when an option is selected, multiple is true, and closeOnSelect option is true', (done) => {
|
||||||
const vm = new Vue({
|
const vm = new Vue({
|
||||||
template: '<div><v-select ref="select" :options="options" multiple closeOnMultiSelect :value="value"></v-select></div>',
|
template: '<div><v-select ref="select" :options="options" multiple :value="value"></v-select></div>',
|
||||||
components: {vSelect},
|
components: {vSelect},
|
||||||
data: {
|
data: {
|
||||||
value: [],
|
value: [],
|
||||||
@@ -370,6 +371,25 @@ describe('Select.vue', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('does not close the dropdown when the el is clicked, multiple is true, and closeOnSelect option is false', (done) => {
|
||||||
|
const vm = new Vue({
|
||||||
|
template: '<div><v-select ref="select" :options="options" multiple :closeOnSelect="false" :value="value"></v-select></div>',
|
||||||
|
components: {vSelect},
|
||||||
|
data: {
|
||||||
|
value: [],
|
||||||
|
options: ['one', 'two', 'three']
|
||||||
|
}
|
||||||
|
}).$mount()
|
||||||
|
|
||||||
|
vm.$children[0].open = true
|
||||||
|
vm.$refs.select.select('one')
|
||||||
|
|
||||||
|
Vue.nextTick(() => {
|
||||||
|
expect(vm.$children[0].open).toEqual(true)
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
it('should close the dropdown on search blur', () => {
|
it('should close the dropdown on search blur', () => {
|
||||||
const vm = new Vue({
|
const vm = new Vue({
|
||||||
|
|||||||
Reference in New Issue
Block a user