mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-07 07:12:23 +03:00
feat: option selection events (#1324)
- `option:selecting` before state is set - `option:selected` after state is set - `option:deselecting` before state is set - `option:deselected` after state is set Co-authored-by: tiagoroldao <troldao@assurehedge.com> Co-authored-by: Jeff <sagalbot@gmail.com>
This commit is contained in:
@@ -657,6 +657,7 @@
|
||||
* @return {void}
|
||||
*/
|
||||
select(option) {
|
||||
this.$emit('option:selecting', option);
|
||||
if (!this.isOptionSelected(option)) {
|
||||
if (this.taggable && !this.optionExists(option)) {
|
||||
this.$emit('option:created', option);
|
||||
@@ -665,6 +666,7 @@
|
||||
option = this.selectedValue.concat(option)
|
||||
}
|
||||
this.updateValue(option);
|
||||
this.$emit('option:selected', option);
|
||||
}
|
||||
this.onAfterSelect(option)
|
||||
},
|
||||
@@ -675,9 +677,11 @@
|
||||
* @return {void}
|
||||
*/
|
||||
deselect (option) {
|
||||
this.$emit('option:deselecting', option);
|
||||
this.updateValue(this.selectedValue.filter(val => {
|
||||
return !this.optionComparator(val, option);
|
||||
}));
|
||||
this.$emit('option:deselected', option);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user