From 946ba25eaff715ee986927acfef3880fb787041b Mon Sep 17 00:00:00 2001 From: ajuner <106791576@qq.com> Date: Fri, 19 Mar 2021 23:05:54 +0800 Subject: [PATCH] fix: Microsoft input triggers onchange twice --- components/vc-input-number/src/index.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/components/vc-input-number/src/index.js b/components/vc-input-number/src/index.js index 79091a2406..bbdc4a1001 100755 --- a/components/vc-input-number/src/index.js +++ b/components/vc-input-number/src/index.js @@ -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}