fix: Microsoft input triggers onchange twice (#3825)

pull/3843/head
ajuner 2021-03-20 14:29:23 +08:00 committed by GitHub
parent cdde89b17e
commit e0967d9d7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 1 deletions

View File

@ -264,6 +264,10 @@ export default {
this.$emit('keyup', e, ...args);
},
onTrigger(e) {
if (e.target.composing) return false;
this.onChange(e);
},
onChange(e) {
if (this.focused) {
this.inputting = true;
@ -621,6 +625,13 @@ export default {
handleInputClick() {
this.$emit('click');
},
onCompositionstart(e) {
e.target.composing = true;
},
onCompositionend(e) {
this.onChange(e);
e.target.composing = false;
},
},
render() {
const {
@ -775,7 +786,9 @@ export default {
name={this.name}
title={this.title}
id={this.id}
onInput={this.onChange}
onInput={this.onTrigger}
onCompositionstart={this.onCompositionstart}
onCompositionend={this.onCompositionend}
ref="inputRef"
value={inputDisplayValue}
pattern={this.pattern}