File tree Expand file tree Collapse file tree 3 files changed +39
-2
lines changed Expand file tree Collapse file tree 3 files changed +39
-2
lines changed Original file line number Diff line number Diff line change 9
9
<!--<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">-->
10
10
<!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0/css/bootstrap.min.css">-->
11
11
< style >
12
-
12
+
13
13
# app {
14
14
height : 95vh ;
15
15
display : flex;
67
67
</ button >
68
68
</ span >
69
69
</ v-select >
70
-
70
+ < v-select placeholder =" select on tab " :select-on-tab =" true " :options =" options " > </ v-select >
71
71
< v-select placeholder ="disabled " disabled value ="disabled "> </ v-select >
72
72
< v-select placeholder ="disabled multiple " disabled multiple :value ="['disabled', 'multiple'] "> </ v-select >
73
73
< v-select placeholder ="filterable=false, @search=searchPeople " label ="first_name " :filterable ="false " @search ="searchPeople " :options ="people "> </ v-select >
Original file line number Diff line number Diff line change 339
339
@keydown.up.prevent =" typeAheadUp"
340
340
@keydown.down.prevent =" typeAheadDown"
341
341
@keydown.enter.prevent =" typeAheadSelect"
342
+ @keydown.tab =" onTab"
342
343
@blur =" onSearchBlur"
343
344
@focus =" onSearchFocus"
344
345
type =" search"
578
579
}
579
580
},
580
581
582
+ /**
583
+ * Select the current value if selectOnTab is enabled
584
+ */
585
+ onTab: {
586
+ type: Function ,
587
+ default : function () {
588
+ if (this .selectOnTab ) {
589
+ this .typeAheadSelect ();
590
+ }
591
+ },
592
+ },
593
+
581
594
/**
582
595
* Enable/disable creating options from searchInput.
583
596
* @type {Boolean}
710
723
type: String ,
711
724
default: ' auto'
712
725
},
726
+ /**
727
+ * When true, hitting the 'tab' key will select the current select value
728
+ * @type {Boolean}
729
+ */
730
+ selectOnTab: {
731
+ type: Boolean ,
732
+ default: false
733
+ }
713
734
},
714
735
715
736
data () {
Original file line number Diff line number Diff line change @@ -109,6 +109,22 @@ describe('Select.vue', () => {
109
109
expect ( vm . $children [ 0 ] . mutableValue ) . toEqual ( vm . value )
110
110
} )
111
111
112
+ it ( 'can select an option on tab' , ( done ) => {
113
+ const vm = new Vue ( {
114
+ template : `<div><v-select :options="['one','two']" select-on-tab></v-select></div>` ,
115
+ components : { vSelect} ,
116
+ } ) . $mount ( )
117
+
118
+ vm . $children [ 0 ] . typeAheadPointer = 0
119
+
120
+ trigger ( vm . $children [ 0 ] . $refs . search , 'keydown' , ( e ) => e . keyCode = 9 )
121
+
122
+ Vue . nextTick ( ( ) => {
123
+ expect ( vm . $children [ 0 ] . mutableValue ) . toEqual ( 'one' ) ;
124
+ done ( ) ;
125
+ } )
126
+ } )
127
+
112
128
it ( 'can deselect a pre-selected object' , ( ) => {
113
129
const vm = new Vue ( {
114
130
template : '<div><v-select :options="options" :value="value" :multiple="true"></v-select></div>' ,
You can’t perform that action at this time.
0 commit comments