Skip to content
Open
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
17 changes: 15 additions & 2 deletions src/components/select/option.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
return (this.label) ? this.label : this.value;
},
optionLabel(){
return this.label || (this.$el && this.$el.textContent);
return this.label || this.searchLabel;
},
isFocused(){
const SelectInstance = this.SelectInstance;
Expand Down Expand Up @@ -103,7 +103,7 @@
const filterByLabel = SelectInstance.filterByLabel;
const slotOptionsMap = SelectInstance.slotOptionsMap;
const { props } = slotOptionsMap.get(this.value) || { props: {} };
const label = this.label || this.$el && this.$el.textContent;
const label = this.label || this.searchLabel;
let filterOption = String(label ?? props.value ?? '').toLowerCase();
if (filterByLabel) {
filterOption = String(label != null ? label : '').toLowerCase();
Expand Down Expand Up @@ -168,13 +168,26 @@
created(){
this.instance = getCurrentInstance();
},
updated () {
this.searchLabel = (this.$el && this.$el.textContent) || '';
},
mounted () {
this.searchLabel = (this.$el && this.$el.textContent) || '';
this.addOption();
const Select = findComponentUpward(this, 'iSelect');
if (Select) {
this.autoComplete = Select.autoComplete;
}
},
watch: {
value (newVal, oldVal) {
const select = this.SelectInstance;
if (select && newVal !== oldVal) {
select.slotOptionsMap.has(oldVal) && select.slotOptionsMap.delete(oldVal);
select.slotOptionsMap.set(newVal, this.instance);
}
}
},
beforeUnmount () {
// fix AutoComplete. when suggest the word, the dropdown will hide
nextTick(() => {
Expand Down