mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-16 09:10:33 +03:00
Pull onTab up to prop, add test
This commit is contained in:
+12
-10
@@ -549,6 +549,18 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Select the current value if selectOnTab is enabled
|
||||||
|
*/
|
||||||
|
onTab: {
|
||||||
|
type: Function,
|
||||||
|
default: function () {
|
||||||
|
if (this.selectOnTab) {
|
||||||
|
this.typeAheadSelect();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable/disable creating options from searchInput.
|
* Enable/disable creating options from searchInput.
|
||||||
* @type {Boolean}
|
* @type {Boolean}
|
||||||
@@ -927,16 +939,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Select the current value if selectOnTab is enabled
|
|
||||||
* @return {void}
|
|
||||||
*/
|
|
||||||
onTab() {
|
|
||||||
if (this.selectOnTab) {
|
|
||||||
this.typeAheadSelect();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if an option exists
|
* Determine if an option exists
|
||||||
* within this.mutableOptions array.
|
* within this.mutableOptions array.
|
||||||
|
|||||||
@@ -109,6 +109,22 @@ describe('Select.vue', () => {
|
|||||||
expect(vm.$children[0].mutableValue).toEqual(vm.value)
|
expect(vm.$children[0].mutableValue).toEqual(vm.value)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('can select an option on tab', (done) => {
|
||||||
|
const vm = new Vue({
|
||||||
|
template: `<div><v-select :options="['one','two']" select-on-tab></v-select></div>`,
|
||||||
|
components: {vSelect},
|
||||||
|
}).$mount()
|
||||||
|
|
||||||
|
vm.$children[0].typeAheadPointer = 0
|
||||||
|
|
||||||
|
trigger(vm.$children[0].$refs.search, 'keydown', (e) => e.keyCode = 9)
|
||||||
|
|
||||||
|
Vue.nextTick(() => {
|
||||||
|
expect(vm.$children[0].mutableValue).toEqual('one');
|
||||||
|
done();
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
it('can deselect a pre-selected object', () => {
|
it('can deselect a pre-selected object', () => {
|
||||||
const vm = new Vue({
|
const vm = new Vue({
|
||||||
template: '<div><v-select :options="options" :value="value" :multiple="true"></v-select></div>',
|
template: '<div><v-select :options="options" :value="value" :multiple="true"></v-select></div>',
|
||||||
|
|||||||
Reference in New Issue
Block a user