Skip to content

Commit

Permalink
Input: Fix Korean composition event (ElemeFE#15069)
Browse files Browse the repository at this point in the history
  • Loading branch information
MoonHyuk authored and oleksiikhr committed Jan 13, 2020
1 parent 0f8586a commit ed99c15
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/input/src/input.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
:autocomplete="autoComplete || autocomplete"
ref="input"
@compositionstart="handleCompositionStart"
@compositionupdate="handleCompositionUpdate"
@compositionend="handleCompositionEnd"
@input="handleInput"
@focus="handleFocus"
Expand Down Expand Up @@ -87,6 +88,7 @@
:tabindex="tabindex"
class="el-textarea__inner"
@compositionstart="handleCompositionStart"
@compositionupdate="handleCompositionUpdate"
@compositionend="handleCompositionEnd"
@input="handleInput"
ref="textarea"
Expand All @@ -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',
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ed99c15

Please sign in to comment.