|
@@ -153,8 +153,13 @@
|
|
|
},
|
|
|
|
|
|
beforeDestroy() {
|
|
|
+ const { selected, multiple } = this.select;
|
|
|
+ let selectedOptions = multiple ? selected : [selected];
|
|
|
let index = this.select.cachedOptions.indexOf(this);
|
|
|
- if (index > -1) {
|
|
|
+ let selectedIndex = selectedOptions.indexOf(this);
|
|
|
+
|
|
|
+ // if option is not selected, remove it from cache
|
|
|
+ if (index > -1 && selectedIndex < 0) {
|
|
|
this.select.cachedOptions.splice(index, 1);
|
|
|
}
|
|
|
this.select.onOptionDestroy(this.select.options.indexOf(this));
|