mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-16 09:10:33 +03:00
add filter prop allowing full customization of filtering
This commit is contained in:
@@ -499,6 +499,19 @@
|
||||
}
|
||||
},
|
||||
|
||||
filter: {
|
||||
"type": Function,
|
||||
default(vm) {
|
||||
return vm.mutableOptions.filter((option) => {
|
||||
let label = vm.getOptionLabel(option)
|
||||
if (typeof label === 'number') {
|
||||
label = label.toString()
|
||||
}
|
||||
return this.filterFunction(option, label, vm.search)
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* An optional callback function that is called each time the selected
|
||||
* value(s) change. When integrating with Vuex, use this callback to trigger
|
||||
@@ -916,14 +929,8 @@
|
||||
* @return {array}
|
||||
*/
|
||||
filteredOptions() {
|
||||
let options = this.mutableOptions.filter((option) => {
|
||||
let label = this.getOptionLabel(option)
|
||||
if (typeof label === 'number') {
|
||||
label = label.toString()
|
||||
}
|
||||
return this.filterFunction(option, label, this.search)
|
||||
})
|
||||
if (this.taggable && this.search.length && !this.optionExists(this.search)) {
|
||||
let options = this.search.length ? this.filter(this) : this.mutableOptions;
|
||||
if (this.taggable && !this.optionExists(this.search)) {
|
||||
options.unshift(this.search)
|
||||
}
|
||||
return options
|
||||
|
||||
Reference in New Issue
Block a user