Skip to content

Commit 57e9007

Browse files
luckyCaoisland205
authored andcommitted
Select: Fix tag show value or empty issue (17199) (ElemeFE#17396)
* Select: Fix tag show value or empty issue * update docs
1 parent 068b3ad commit 57e9007

File tree

5 files changed

+10
-5
lines changed

5 files changed

+10
-5
lines changed

examples/docs/en-US/select.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ Enter keywords and search data from server.
453453
},
454454
mounted() {
455455
this.list = this.states.map(item => {
456-
return { value: item, label: item };
456+
return { value: `value:${item}`, label: `label:${item}` };
457457
});
458458
},
459459
methods: {

examples/docs/es/select.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ Introduzca palabras y datos para buscar desde el servidor.
457457
},
458458
mounted() {
459459
this.list = this.states.map(item => {
460-
return { value: item, label: item };
460+
return { value: `value:${item}`, label: `label:${item}` };
461461
});
462462
},
463463
methods: {

examples/docs/fr-FR/select.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ Vous pouvez aller chercher les options sur le serveur de manière dynamique.
453453
},
454454
mounted() {
455455
this.list = this.states.map(item => {
456-
return { value: item, label: item };
456+
return { value: `value:${item}`, label: `label:${item}` };
457457
});
458458
},
459459
methods: {

examples/docs/zh-CN/select.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@
448448
},
449449
mounted() {
450450
this.list = this.states.map(item => {
451-
return { value: item, label: item };
451+
return { value: `value:${item}`, label: `label:${item}` };
452452
});
453453
},
454454
methods: {

packages/select/src/option.vue

+6-1
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,13 @@
153153
},
154154
155155
beforeDestroy() {
156+
const { selected, multiple } = this.select;
157+
let selectedOptions = multiple ? selected : [selected];
156158
let index = this.select.cachedOptions.indexOf(this);
157-
if (index > -1) {
159+
let selectedIndex = selectedOptions.indexOf(this);
160+
161+
// if option is not selected, remove it from cache
162+
if (index > -1 && selectedIndex < 0) {
158163
this.select.cachedOptions.splice(index, 1);
159164
}
160165
this.select.onOptionDestroy(this.select.options.indexOf(this));

0 commit comments

Comments
 (0)