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

Add select on tab option and example

This commit is contained in:
Kevin Ball
2018-06-05 15:47:52 -07:00
parent 867a74cddb
commit d2efc965f9
2 changed files with 27 additions and 7 deletions
+2 -1
View File
@@ -9,7 +9,7 @@
<!--<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">--> <!--<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">-->
<!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0/css/bootstrap.min.css">--> <!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0/css/bootstrap.min.css">-->
<style> <style>
#app { #app {
height: 95vh; height: 95vh;
display: flex; display: flex;
@@ -68,6 +68,7 @@
</span> </span>
</v-select> </v-select>
<v-select placeholder="select on tab" :select-on-tab="true" :options="options"></v-select>
<v-select placeholder="disabled" disabled value="disabled"></v-select> <v-select placeholder="disabled" disabled value="disabled"></v-select>
<v-select placeholder="disabled multiple" disabled multiple :value="['disabled', 'multiple']"></v-select> <v-select placeholder="disabled multiple" disabled multiple :value="['disabled', 'multiple']"></v-select>
<v-select placeholder="filterable=false, @search=searchPeople" label="first_name" :filterable="false" @search="searchPeople" :options="people"></v-select> <v-select placeholder="filterable=false, @search=searchPeople" label="first_name" :filterable="false" @search="searchPeople" :options="people"></v-select>
+25 -6
View File
@@ -329,6 +329,7 @@
v-model="search" v-model="search"
@keydown.delete="maybeDeleteValue" @keydown.delete="maybeDeleteValue"
@keyup.esc="onEscape" @keyup.esc="onEscape"
@keydown.tab="onTab"
@keydown.up.prevent="typeAheadUp" @keydown.up.prevent="typeAheadUp"
@keydown.down.prevent="typeAheadDown" @keydown.down.prevent="typeAheadDown"
@keydown.enter.prevent="typeAheadSelect" @keydown.enter.prevent="typeAheadSelect"
@@ -346,13 +347,13 @@
aria-label="Search for option" aria-label="Search for option"
> >
<button <button
v-show="showClearButton" v-show="showClearButton"
:disabled="disabled" :disabled="disabled"
@click="clearSelection" @click="clearSelection"
type="button" type="button"
class="clear" class="clear"
title="Clear selection" title="Clear selection"
> >
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</button> </button>
@@ -680,6 +681,14 @@
type: String, type: String,
default: 'auto' default: 'auto'
}, },
/**
* When true, hitting the 'tab' key will select the current select value
* @type {Boolean}
*/
selectOnTab: {
type: Boolean,
default: false
}
}, },
data() { data() {
@@ -918,6 +927,16 @@
} }
}, },
/**
* 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.