2
0
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:
Tiago Roldão
2020-12-18 21:18:34 +01:00
committed by GitHub
parent f947e253c5
commit 6e1c0dbcbd
3 changed files with 116 additions and 1 deletions
+4
View File
@@ -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);
},
/**