Skip to content

Commit e0967d9

Browse files
authored
fix: Microsoft input triggers onchange twice (#3825)
1 parent cdde89b commit e0967d9

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

components/vc-input-number/src/index.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,10 @@ export default {
264264

265265
this.$emit('keyup', e, ...args);
266266
},
267+
onTrigger(e) {
268+
if (e.target.composing) return false;
269+
this.onChange(e);
270+
},
267271
onChange(e) {
268272
if (this.focused) {
269273
this.inputting = true;
@@ -621,6 +625,13 @@ export default {
621625
handleInputClick() {
622626
this.$emit('click');
623627
},
628+
onCompositionstart(e) {
629+
e.target.composing = true;
630+
},
631+
onCompositionend(e) {
632+
this.onChange(e);
633+
e.target.composing = false;
634+
},
624635
},
625636
render() {
626637
const {
@@ -775,7 +786,9 @@ export default {
775786
name={this.name}
776787
title={this.title}
777788
id={this.id}
778-
onInput={this.onChange}
789+
onInput={this.onTrigger}
790+
onCompositionstart={this.onCompositionstart}
791+
onCompositionend={this.onCompositionend}
779792
ref="inputRef"
780793
value={inputDisplayValue}
781794
pattern={this.pattern}

0 commit comments

Comments
 (0)