Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select: Fix tag show value or empty issue (17199) #17396

Merged
merged 2 commits into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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