Select: fix a dropdown update bug (#1784)

pull/1818/head
杨奕 2016-12-18 21:24:02 +08:00 committed by baiyaaaaa
parent 8123ee1c48
commit 92742dc56a
2 changed files with 16 additions and 6 deletions

View File

@ -86,6 +86,20 @@
} }
}, },
watch: {
currentLabel() {
this.dispatch('ElSelect', 'setSelected');
},
value() {
this.dispatch('ElSelect', 'setSelected');
},
visible() {
this.$nextTick(() => {
this.dispatch('ElSelectDropdown', 'updatePopper');
});
}
},
methods: { methods: {
handleGroupDisabled(val) { handleGroupDisabled(val) {
this.groupDisabled = val; this.groupDisabled = val;

View File

@ -194,7 +194,6 @@
selectedLabel: '', selectedLabel: '',
hoverIndex: -1, hoverIndex: -1,
query: '', query: '',
isForcedVisible: false,
bottomOverflowBeforeHidden: 0, bottomOverflowBeforeHidden: 0,
topOverflowBeforeHidden: 0, topOverflowBeforeHidden: 0,
optionsAllDisabled: false, optionsAllDisabled: false,
@ -231,10 +230,6 @@
if (this.multiple && this.filterable) { if (this.multiple && this.filterable) {
this.resetInputHeight(); this.resetInputHeight();
} }
if (this.isForcedVisible) {
this.isForcedVisible = false;
return;
}
if (this.remote && typeof this.remoteMethod === 'function') { if (this.remote && typeof this.remoteMethod === 'function') {
this.hoverIndex = -1; this.hoverIndex = -1;
this.remoteMethod(val); this.remoteMethod(val);
@ -271,6 +266,7 @@
this.getOverflows(); this.getOverflows();
if (this.selected) { if (this.selected) {
this.selectedLabel = this.selected.currentLabel; this.selectedLabel = this.selected.currentLabel;
if (this.filterable) this.query = this.selectedLabel;
} }
} }
} else { } else {
@ -282,7 +278,6 @@
this.$refs.input.focus(); this.$refs.input.focus();
} else { } else {
if (!this.remote) { if (!this.remote) {
this.isForcedVisible = true;
this.broadcast('ElOption', 'queryChange', ''); this.broadcast('ElOption', 'queryChange', '');
} }
this.broadcast('ElInput', 'inputSelect'); this.broadcast('ElInput', 'inputSelect');
@ -593,6 +588,7 @@
this.$on('handleOptionClick', this.handleOptionSelect); this.$on('handleOptionClick', this.handleOptionSelect);
this.$on('onOptionDestroy', this.onOptionDestroy); this.$on('onOptionDestroy', this.onOptionDestroy);
this.$on('setSelected', this.setSelected);
}, },
mounted() { mounted() {