File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -131,6 +131,12 @@ new Vue {
131
131
<td ><code >false</code ></td >
132
132
<td >Case sensitive for suggestions.</td >
133
133
</tr >
134
+ <tr >
135
+ <td >match-start</td >
136
+ <td ><code >Boolean</code ></td >
137
+ <td ><code >false</code ></td >
138
+ <td >Match only against start of suggestions. E.g. if true, "a" matches "ab" but not "ba".</td >
139
+ </tr >
134
140
<tr >
135
141
<td >on-hit</td >
136
142
<td ><code >Function</code ></td >
Original file line number Diff line number Diff line change @@ -61,6 +61,11 @@ const typeahead = {
61
61
coerce: coerceBoolean,
62
62
default: false
63
63
},
64
+ matchStart: {
65
+ type: Boolean ,
66
+ coerce: coerceBoolean,
67
+ default: false
68
+ },
64
69
onHit: {
65
70
type: Function ,
66
71
default (items ) {
@@ -87,7 +92,7 @@ const typeahead = {
87
92
return this .data .filter (value => {
88
93
value = this .matchCase ? value : value .toLowerCase ();
89
94
var query = this .matchCase ? this .query : this .query .toLowerCase ();
90
- return value .indexOf (query) !== - 1 ;
95
+ return this . matchStart ? value . indexOf (query) === 0 : value .indexOf (query) !== - 1 ;
91
96
}).slice (0 , this .limit )
92
97
}
93
98
}
You can’t perform that action at this time.
0 commit comments