Commit f43bc792befba702245d8f742086a307c5a44f90
1 parent
57bd5393
fix #5060
Showing
1 changed file
with
19 additions
and
1 deletions
Show diff stats
src/components/input/input.vue
| @@ -30,6 +30,9 @@ | @@ -30,6 +30,9 @@ | ||
| 30 | @keydown="handleKeydown" | 30 | @keydown="handleKeydown" |
| 31 | @focus="handleFocus" | 31 | @focus="handleFocus" |
| 32 | @blur="handleBlur" | 32 | @blur="handleBlur" |
| 33 | + @compositionstart="handleComposition" | ||
| 34 | + @compositionupdate="handleComposition" | ||
| 35 | + @compositionend="handleComposition" | ||
| 33 | @input="handleInput" | 36 | @input="handleInput" |
| 34 | @change="handleChange"> | 37 | @change="handleChange"> |
| 35 | <div :class="[prefixCls + '-group-append']" v-if="append" v-show="slotReady"><slot name="append"></slot></div> | 38 | <div :class="[prefixCls + '-group-append']" v-if="append" v-show="slotReady"><slot name="append"></slot></div> |
| @@ -62,6 +65,9 @@ | @@ -62,6 +65,9 @@ | ||
| 62 | @keydown="handleKeydown" | 65 | @keydown="handleKeydown" |
| 63 | @focus="handleFocus" | 66 | @focus="handleFocus" |
| 64 | @blur="handleBlur" | 67 | @blur="handleBlur" |
| 68 | + @compositionstart="handleComposition" | ||
| 69 | + @compositionupdate="handleComposition" | ||
| 70 | + @compositionend="handleComposition" | ||
| 65 | @input="handleInput"> | 71 | @input="handleInput"> |
| 66 | </textarea> | 72 | </textarea> |
| 67 | </div> | 73 | </div> |
| @@ -179,7 +185,8 @@ | @@ -179,7 +185,8 @@ | ||
| 179 | slotReady: false, | 185 | slotReady: false, |
| 180 | textareaStyles: {}, | 186 | textareaStyles: {}, |
| 181 | showPrefix: false, | 187 | showPrefix: false, |
| 182 | - showSuffix: false | 188 | + showSuffix: false, |
| 189 | + isOnComposition: false | ||
| 183 | }; | 190 | }; |
| 184 | }, | 191 | }, |
| 185 | computed: { | 192 | computed: { |
| @@ -244,7 +251,18 @@ | @@ -244,7 +251,18 @@ | ||
| 244 | this.dispatch('FormItem', 'on-form-blur', this.currentValue); | 251 | this.dispatch('FormItem', 'on-form-blur', this.currentValue); |
| 245 | } | 252 | } |
| 246 | }, | 253 | }, |
| 254 | + handleComposition(event) { | ||
| 255 | + if (event.type === 'compositionstart') { | ||
| 256 | + this.isOnComposition = true; | ||
| 257 | + } | ||
| 258 | + if (event.type === 'compositionend') { | ||
| 259 | + this.isOnComposition = false; | ||
| 260 | + this.handleInput(event); | ||
| 261 | + } | ||
| 262 | + }, | ||
| 247 | handleInput (event) { | 263 | handleInput (event) { |
| 264 | + if (this.isOnComposition) return; | ||
| 265 | + | ||
| 248 | let value = event.target.value; | 266 | let value = event.target.value; |
| 249 | if (this.number && value !== '') value = Number.isNaN(Number(value)) ? value : Number(value); | 267 | if (this.number && value !== '') value = Number.isNaN(Number(value)) ? value : Number(value); |
| 250 | this.$emit('input', value); | 268 | this.$emit('input', value); |