mirror of https://github.com/ElemeFE/element
Autocomplete: fix problem when input with Chinese input method (#4393)
parent
92b4156aaa
commit
90eb1e1927
|
@ -9,6 +9,9 @@
|
||||||
:size="size"
|
:size="size"
|
||||||
:icon="icon"
|
:icon="icon"
|
||||||
:on-icon-click="onIconClick"
|
:on-icon-click="onIconClick"
|
||||||
|
@compositionstart.native="handleComposition"
|
||||||
|
@compositionupdate.native="handleComposition"
|
||||||
|
@compositionend.native="handleComposition"
|
||||||
@change="handleChange"
|
@change="handleChange"
|
||||||
@focus="handleFocus"
|
@focus="handleFocus"
|
||||||
@blur="handleBlur"
|
@blur="handleBlur"
|
||||||
|
@ -71,6 +74,7 @@
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
isFocus: false,
|
isFocus: false,
|
||||||
|
isOnComposition: false,
|
||||||
suggestions: [],
|
suggestions: [],
|
||||||
loading: false,
|
loading: false,
|
||||||
highlightedIndex: -1
|
highlightedIndex: -1
|
||||||
|
@ -100,9 +104,17 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
handleComposition(event) {
|
||||||
|
if (event.type === 'compositionend') {
|
||||||
|
this.isOnComposition = false;
|
||||||
|
this.handleChange(event.data);
|
||||||
|
} else {
|
||||||
|
this.isOnComposition = true;
|
||||||
|
}
|
||||||
|
},
|
||||||
handleChange(value) {
|
handleChange(value) {
|
||||||
this.$emit('input', value);
|
this.$emit('input', value);
|
||||||
if (!this.triggerOnFocus && !value) {
|
if (this.isOnComposition || (!this.triggerOnFocus && !value)) {
|
||||||
this.suggestions = [];
|
this.suggestions = [];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue