|
29 | 29 | :readonly="readonly"
|
30 | 30 | :autocomplete="autoComplete || autocomplete"
|
31 | 31 | ref="input"
|
32 |
| - @compositionstart="handleCompositionStart" |
33 |
| - @compositionend="handleCompositionEnd" |
| 32 | + @compositionstart="handleComposition" |
| 33 | + @compositionupdate="handleComposition" |
| 34 | + @compositionend="handleComposition" |
34 | 35 | @input="handleInput"
|
35 | 36 | @focus="handleFocus"
|
36 | 37 | @blur="handleBlur"
|
|
80 | 81 | v-else
|
81 | 82 | :tabindex="tabindex"
|
82 | 83 | class="el-textarea__inner"
|
83 |
| - @compositionstart="handleCompositionStart" |
84 |
| - @compositionend="handleCompositionEnd" |
| 84 | + @compositionstart="handleComposition" |
| 85 | + @compositionupdate="handleComposition" |
| 86 | + @compositionend="handleComposition" |
85 | 87 | @input="handleInput"
|
86 | 88 | ref="textarea"
|
87 | 89 | v-bind="$attrs"
|
|
102 | 104 | import Migrating from 'element-ui/src/mixins/migrating';
|
103 | 105 | import calcTextareaHeight from './calcTextareaHeight';
|
104 | 106 | import merge from 'element-ui/src/utils/merge';
|
| 107 | + import {isKorean} from 'element-ui/src/utils/shared'; |
105 | 108 |
|
106 | 109 | export default {
|
107 | 110 | name: 'ElInput',
|
|
299 | 302 | this.focused = true;
|
300 | 303 | this.$emit('focus', event);
|
301 | 304 | },
|
302 |
| - handleCompositionStart() { |
303 |
| - this.isComposing = true; |
304 |
| - }, |
305 |
| - handleCompositionEnd(event) { |
306 |
| - this.isComposing = false; |
307 |
| - this.handleInput(event); |
| 305 | + handleComposition(event) { |
| 306 | + const text = event.target.value; |
| 307 | + if (event.type === 'compositionend' && this.isComposing) { |
| 308 | + this.isComposing = false; |
| 309 | + this.handleInput(event); |
| 310 | + } else { |
| 311 | + const lastCharacter = text[text.length - 1] || ''; |
| 312 | + this.isComposing = !isKorean(lastCharacter); |
| 313 | + } |
308 | 314 | },
|
309 | 315 | handleInput(event) {
|
310 | 316 | // should not emit input during composition
|
|
0 commit comments