Skip to content

Commit

Permalink
Select: Fix tag show value or empty issue (17199) (#17396)
Browse files Browse the repository at this point in the history
* Select: Fix tag show value or empty issue

* update docs
  • Loading branch information
luckyCao authored and island205 committed Nov 12, 2019
1 parent 068b3ad commit 57e9007
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/docs/en-US/select.md
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ Enter keywords and search data from server.
},
mounted() {
this.list = this.states.map(item => {
return { value: item, label: item };
return { value: `value:${item}`, label: `label:${item}` };
});
},
methods: {
Expand Down
2 changes: 1 addition & 1 deletion examples/docs/es/select.md
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ Introduzca palabras y datos para buscar desde el servidor.
},
mounted() {
this.list = this.states.map(item => {
return { value: item, label: item };
return { value: `value:${item}`, label: `label:${item}` };
});
},
methods: {
Expand Down
2 changes: 1 addition & 1 deletion examples/docs/fr-FR/select.md
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ Vous pouvez aller chercher les options sur le serveur de manière dynamique.
},
mounted() {
this.list = this.states.map(item => {
return { value: item, label: item };
return { value: `value:${item}`, label: `label:${item}` };
});
},
methods: {
Expand Down
2 changes: 1 addition & 1 deletion examples/docs/zh-CN/select.md
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@
},
mounted() {
this.list = this.states.map(item => {
return { value: item, label: item };
return { value: `value:${item}`, label: `label:${item}` };
});
},
methods: {
Expand Down
7 changes: 6 additions & 1 deletion packages/select/src/option.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 57e9007

Please sign in to comment.