From e9c5e469c1c9d236a6c875658cbb311f9fc2c9c9 Mon Sep 17 00:00:00 2001 From: Moonhyuk Im Date: Thu, 8 Aug 2019 15:03:48 +0900 Subject: [PATCH] Input: Fix Korean composition event (#15069) --- packages/input/src/input.vue | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/input/src/input.vue b/packages/input/src/input.vue index 98ef1dc04..fbe9b00dd 100644 --- a/packages/input/src/input.vue +++ b/packages/input/src/input.vue @@ -31,6 +31,7 @@ :autocomplete="autoComplete || autocomplete" ref="input" @compositionstart="handleCompositionStart" + @compositionupdate="handleCompositionUpdate" @compositionend="handleCompositionEnd" @input="handleInput" @focus="handleFocus" @@ -87,6 +88,7 @@ :tabindex="tabindex" class="el-textarea__inner" @compositionstart="handleCompositionStart" + @compositionupdate="handleCompositionUpdate" @compositionend="handleCompositionEnd" @input="handleInput" ref="textarea" @@ -109,6 +111,7 @@ import Migrating from 'element-ui/src/mixins/migrating'; import calcTextareaHeight from './calcTextareaHeight'; import merge from 'element-ui/src/utils/merge'; + import {isKorean} from 'element-ui/src/utils/shared'; export default { name: 'ElInput', @@ -336,9 +339,16 @@ handleCompositionStart() { this.isComposing = true; }, + handleCompositionUpdate(event) { + const text = event.target.value; + const lastCharacter = text[text.length - 1] || ''; + this.isComposing = !isKorean(lastCharacter); + }, handleCompositionEnd(event) { - this.isComposing = false; - this.handleInput(event); + if (this.isComposing) { + this.isComposing = false; + this.handleInput(event); + } }, handleInput(event) { // should not emit input during composition