Skip to content

Commit 73e67a6

Browse files
author
Jeff
committed
- add dev example
- rename `filterOptions` prop to `filterable` - update tests
1 parent 283cb4f commit 73e67a6

File tree

4 files changed

+24
-12
lines changed

4 files changed

+24
-12
lines changed

dev.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
</v-select>
5151
<v-select disabled placeholder="disabled" value="disabled"></v-select>
5252
<v-select disabled multiple placeholder="disabled" :value="['disabled', 'multiple']"></v-select>
53+
<v-select placeholder="filterable=false, @search=searchPeople" label="first_name" :filterable="false" @search="searchPeople" :options="people"></v-select>
5354
</div>
5455
</body>
5556

src/components/Select.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@
526526
* with taggable.
527527
* @type {Boolean}
528528
*/
529-
filterOptions: {
529+
filterable: {
530530
type: Boolean,
531531
default: true
532532
},
@@ -915,7 +915,7 @@
915915
* @return {array}
916916
*/
917917
filteredOptions() {
918-
if (!this.filterOptions && !this.taggable) {
918+
if (!this.filterable && !this.taggable) {
919919
return this.mutableOptions.slice()
920920
}
921921
let options = this.mutableOptions.filter((option) => {

src/dev.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,24 @@ new Vue({
1717
placeholder: "placeholder",
1818
value: null,
1919
options: countries,
20-
ajaxRes: []
20+
ajaxRes: [],
21+
people: []
2122
},
2223
methods: {
2324
search(search, loading) {
2425
loading(true)
2526
this.getRepositories(search, loading, this)
2627
},
28+
searchPeople(search, loading) {
29+
loading(true)
30+
this.getPeople(loading, this)
31+
},
32+
getPeople: debounce((loading, vm) => {
33+
vm.$http.get(`https://reqres.in/api/users?per_page=10`).then(res => {
34+
vm.people = res.data.data
35+
loading(false)
36+
})
37+
}, 250),
2738
getRepositories: debounce((search, loading, vm) => {
2839
vm.$http.get(`https://api.github.com/search/repositories?q=${search}`).then(res => {
2940
vm.ajaxRes = res.data.items

test/unit/specs/Select.spec.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,9 @@ describe('Select.vue', () => {
295295
expect(vm.$refs.select.filteredOptions).toEqual(['bar','baz'])
296296
})
297297

298-
it('should not filter the array of strings if filterOptions is false', () => {
298+
it('should not filter the array of strings if filterable is false', () => {
299299
const vm = new Vue({
300-
template: `<div><v-select ref="select" :filter-options="false" :options="['foo','bar','baz']" v-model="value"></v-select></div>`,
300+
template: `<div><v-select ref="select" :filterable="false" :options="['foo','bar','baz']" v-model="value"></v-select></div>`,
301301
data: {value: 'foo'}
302302
}).$mount()
303303
vm.$refs.select.search = 'ba'
@@ -897,9 +897,9 @@ describe('Select.vue', () => {
897897
expect(vm.$children[0].mutableOptions).toEqual(['one', 'two', 'three'])
898898
})
899899

900-
it('should add a freshly created option/tag to the options list when pushTags is true and filterOptions is false', () => {
900+
it('should add a freshly created option/tag to the options list when pushTags is true and filterable is false', () => {
901901
const vm = new Vue({
902-
template: '<div><v-select :options="options" push-tags :value="value" :filter-options="false" :multiple="true" :taggable="true"></v-select></div>',
902+
template: '<div><v-select :options="options" push-tags :value="value" :filterable="false" :multiple="true" :taggable="true"></v-select></div>',
903903
components: {vSelect},
904904
data: {
905905
value: ['one'],
@@ -926,9 +926,9 @@ describe('Select.vue', () => {
926926
expect(vm.$children[0].mutableOptions).toEqual(['one', 'two'])
927927
})
928928

929-
it('wont add a freshly created option/tag to the options list when pushTags is false and filterOptions is false', () => {
929+
it('wont add a freshly created option/tag to the options list when pushTags is false and filterable is false', () => {
930930
const vm = new Vue({
931-
template: '<div><v-select :options="options" :value="value" :multiple="true" :filter-options="false" :taggable="true"></v-select></div>',
931+
template: '<div><v-select :options="options" :value="value" :multiple="true" :filterable="false" :taggable="true"></v-select></div>',
932932
components: {vSelect},
933933
data: {
934934
value: ['one'],
@@ -985,7 +985,7 @@ describe('Select.vue', () => {
985985
it('should select an existing option if the search string matches an objects label from options when filter-options is false', (done) => {
986986
let two = {label: 'two'}
987987
const vm = new Vue({
988-
template: '<div><v-select :options="options" taggable :filter-options="false"></v-select></div>',
988+
template: '<div><v-select :options="options" taggable :filterable="false"></v-select></div>',
989989
data: {
990990
options: [{label: 'one'}, two]
991991
}
@@ -1020,9 +1020,9 @@ describe('Select.vue', () => {
10201020
})
10211021
})
10221022

1023-
it('should not reset the selected value when the options property changes when filterOptions is false', (done) => {
1023+
it('should not reset the selected value when the options property changes when filterable is false', (done) => {
10241024
const vm = new Vue({
1025-
template: '<div><v-select :options="options" :value="value" :multiple="true" :filter-options="false" taggable></v-select></div>',
1025+
template: '<div><v-select :options="options" :value="value" :multiple="true" :filterable="false" taggable></v-select></div>',
10261026
components: {vSelect},
10271027
data: {
10281028
value: [{label: 'one'}],

0 commit comments

Comments
 (0)