Skip to content

Commit aad33cb

Browse files
authored
fix: Microsoft input triggers onchange twice (vueComponent#3550)
1 parent ca444b5 commit aad33cb

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
@@ -265,6 +265,10 @@ export default defineComponent({
265265

266266
this.__emit('keyup', e, ...args);
267267
},
268+
onTrigger(e) {
269+
if (e.target.composing) return false;
270+
this.onChange(e);
271+
},
268272
onChange(e) {
269273
if (this.$data.focused) {
270274
this.inputting = true;
@@ -631,6 +635,13 @@ export default defineComponent({
631635
saveInput(node) {
632636
this.inputRef = node;
633637
},
638+
onCompositionstart(e) {
639+
e.target.composing = true;
640+
},
641+
onCompositionend(e) {
642+
this.onChange(e);
643+
e.target.composing = false;
644+
},
634645
},
635646
render() {
636647
const props = { ...this.$props, ...this.$attrs };
@@ -791,7 +802,9 @@ export default defineComponent({
791802
name={this.name}
792803
title={this.title}
793804
id={this.id}
794-
onInput={this.onChange}
805+
onInput={this.onTrigger}
806+
onCompositionstart={this.onCompositionstart}
807+
onCompositionend={this.onCompositionend}
795808
ref={this.saveInput}
796809
value={inputDisplayValue}
797810
pattern={this.pattern}

0 commit comments

Comments
 (0)