Skip to content

Commit 8a5dd7f

Browse files
author
moonhyuk
committed
Input: Fix Korean composition
1 parent 88b628b commit 8a5dd7f

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

packages/input/src/input.vue

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
:readonly="readonly"
3030
:autocomplete="autoComplete || autocomplete"
3131
ref="input"
32-
@compositionstart="handleCompositionStart"
33-
@compositionend="handleCompositionEnd"
32+
@compositionstart="handleComposition"
33+
@compositionupdate="handleComposition"
34+
@compositionend="handleComposition"
3435
@input="handleInput"
3536
@focus="handleFocus"
3637
@blur="handleBlur"
@@ -80,8 +81,9 @@
8081
v-else
8182
:tabindex="tabindex"
8283
class="el-textarea__inner"
83-
@compositionstart="handleCompositionStart"
84-
@compositionend="handleCompositionEnd"
84+
@compositionstart="handleComposition"
85+
@compositionupdate="handleComposition"
86+
@compositionend="handleComposition"
8587
@input="handleInput"
8688
ref="textarea"
8789
v-bind="$attrs"
@@ -102,6 +104,7 @@
102104
import Migrating from 'element-ui/src/mixins/migrating';
103105
import calcTextareaHeight from './calcTextareaHeight';
104106
import merge from 'element-ui/src/utils/merge';
107+
import {isKorean} from 'element-ui/src/utils/shared';
105108
106109
export default {
107110
name: 'ElInput',
@@ -299,12 +302,15 @@
299302
this.focused = true;
300303
this.$emit('focus', event);
301304
},
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+
}
308314
},
309315
handleInput(event) {
310316
// should not emit input during composition

packages/select/src/select.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@
435435
methods: {
436436
handleComposition(event) {
437437
const text = event.target.value;
438-
if (event.type === 'compositionend') {
438+
if (event.type === 'compositionend' && this.isOnComposition) {
439439
this.isOnComposition = false;
440440
this.handleQueryChange(text);
441441
} else {

0 commit comments

Comments
 (0)