Is your feature request related to a problem? Please describe.
It would be great to conditionally close the dropdown when an item is selected
Describe the solution you'd like
Make the closeOnSelect prop able to be a function that takes the list of selected options and/or the option that was just selected. It would return true or false for whether the dropdown should be closed.
Describe alternatives you've considered
I am currently extending VSelect to override the onAfterSelect method:
import VSelect from 'vue-select';
import Vue from 'vue';
Vue.component('VSelect', {
extends: VSelect,
props: {
closeOnSelectFunc: {
type: Function,
default: null
}
},
methods: {
/**
* Override onAfterSelect functionality to allow a function prop that determines if the dropdown should be closed based on what's been selected
* @param option {[]} list of selected options
*/
onAfterSelect (option) {
if (this.closeOnSelect || (this.closeOnSelectFunc && this.closeOnSelectFunc(option))) {
this.open = !this.open;
this.searchEl.blur();
}
if (this.clearSearchOnSelect) {
this.search = '';
}
}
}
});
Is your feature request related to a problem? Please describe. It would be great to conditionally close the dropdown when an item is selected
Describe the solution you'd like Make the
closeOnSelect
prop able to be a function that takes the list of selected options and/or the option that was just selected. It would return true or false for whether the dropdown should be closed.Describe alternatives you've considered I am currently extending VSelect to override the
onAfterSelect
method:and in my component:
Additional context Add any other context or screenshots about the feature request here.