Commit 68c1c848 authored by Leopoldthecoder's avatar Leopoldthecoder

Select: fix allowCreate bug

parent ead1d1da
......@@ -88,10 +88,10 @@
watch: {
currentLabel() {
this.dispatch('ElSelect', 'setSelected');
if (!this.created) this.dispatch('ElSelect', 'setSelected');
},
value() {
this.dispatch('ElSelect', 'setSelected');
if (!this.created) this.dispatch('ElSelect', 'setSelected');
}
},
......
......@@ -98,6 +98,7 @@
import { addClass, removeClass, hasClass } from 'element-ui/src/utils/dom';
import { addResizeListener, removeResizeListener } from 'element-ui/src/utils/resize-event';
import { t } from 'element-ui/src/locale';
import merge from 'element-ui/src/utils/merge';
const sizeMap = {
'large': 42,
'small': 30,
......@@ -191,6 +192,8 @@
return {
options: [],
cachedOptions: [],
createdOption: null,
createdSelected: false,
selected: this.multiple ? [] : {},
isSelect: true,
inputLength: 20,
......@@ -276,7 +279,12 @@
if (!this.multiple) {
this.getOverflows();
if (this.selected) {
this.selectedLabel = this.selected.currentLabel;
if (this.filterable && this.allowCreate &&
this.createdSelected && this.createdOption) {
this.selectedLabel = this.createdOption.currentLabel;
} else {
this.selectedLabel = this.selected.currentLabel;
}
if (this.filterable) this.query = this.selectedLabel;
}
}
......@@ -371,6 +379,12 @@
setSelected() {
if (!this.multiple) {
let option = this.getOption(this.value);
if (option.created) {
this.createdOption = merge({}, option);
this.createdSelected = true;
} else {
this.createdSelected = false;
}
this.selectedLabel = option.currentLabel;
this.selected = option;
return;
......@@ -382,6 +396,9 @@
});
}
this.selected = result;
this.$nextTick(() => {
this.resetInputHeight();
});
},
handleIconClick(event) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment