fix: Microsoft input triggers onchange twice (#3550)

pull/3577/head
ajuner 4 years ago committed by GitHub
parent ca444b549c
commit aad33cb72f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -265,6 +265,10 @@ export default defineComponent({
this.__emit('keyup', e, ...args); this.__emit('keyup', e, ...args);
}, },
onTrigger(e) {
if (e.target.composing) return false;
this.onChange(e);
},
onChange(e) { onChange(e) {
if (this.$data.focused) { if (this.$data.focused) {
this.inputting = true; this.inputting = true;
@ -631,6 +635,13 @@ export default defineComponent({
saveInput(node) { saveInput(node) {
this.inputRef = node; this.inputRef = node;
}, },
onCompositionstart(e) {
e.target.composing = true;
},
onCompositionend(e) {
this.onChange(e);
e.target.composing = false;
},
}, },
render() { render() {
const props = { ...this.$props, ...this.$attrs }; const props = { ...this.$props, ...this.$attrs };
@ -791,7 +802,9 @@ export default defineComponent({
name={this.name} name={this.name}
title={this.title} title={this.title}
id={this.id} id={this.id}
onInput={this.onChange} onInput={this.onTrigger}
onCompositionstart={this.onCompositionstart}
onCompositionend={this.onCompositionend}
ref={this.saveInput} ref={this.saveInput}
value={inputDisplayValue} value={inputDisplayValue}
pattern={this.pattern} pattern={this.pattern}

Loading…
Cancel
Save