mirror of https://github.com/ElemeFE/element
Input: Fix Korean composition event (#15069)
parent
465c38bfaa
commit
e9c5e469c1
|
@ -31,6 +31,7 @@
|
||||||
:autocomplete="autoComplete || autocomplete"
|
:autocomplete="autoComplete || autocomplete"
|
||||||
ref="input"
|
ref="input"
|
||||||
@compositionstart="handleCompositionStart"
|
@compositionstart="handleCompositionStart"
|
||||||
|
@compositionupdate="handleCompositionUpdate"
|
||||||
@compositionend="handleCompositionEnd"
|
@compositionend="handleCompositionEnd"
|
||||||
@input="handleInput"
|
@input="handleInput"
|
||||||
@focus="handleFocus"
|
@focus="handleFocus"
|
||||||
|
@ -87,6 +88,7 @@
|
||||||
:tabindex="tabindex"
|
:tabindex="tabindex"
|
||||||
class="el-textarea__inner"
|
class="el-textarea__inner"
|
||||||
@compositionstart="handleCompositionStart"
|
@compositionstart="handleCompositionStart"
|
||||||
|
@compositionupdate="handleCompositionUpdate"
|
||||||
@compositionend="handleCompositionEnd"
|
@compositionend="handleCompositionEnd"
|
||||||
@input="handleInput"
|
@input="handleInput"
|
||||||
ref="textarea"
|
ref="textarea"
|
||||||
|
@ -109,6 +111,7 @@
|
||||||
import Migrating from 'element-ui/src/mixins/migrating';
|
import Migrating from 'element-ui/src/mixins/migrating';
|
||||||
import calcTextareaHeight from './calcTextareaHeight';
|
import calcTextareaHeight from './calcTextareaHeight';
|
||||||
import merge from 'element-ui/src/utils/merge';
|
import merge from 'element-ui/src/utils/merge';
|
||||||
|
import {isKorean} from 'element-ui/src/utils/shared';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ElInput',
|
name: 'ElInput',
|
||||||
|
@ -336,9 +339,16 @@
|
||||||
handleCompositionStart() {
|
handleCompositionStart() {
|
||||||
this.isComposing = true;
|
this.isComposing = true;
|
||||||
},
|
},
|
||||||
|
handleCompositionUpdate(event) {
|
||||||
|
const text = event.target.value;
|
||||||
|
const lastCharacter = text[text.length - 1] || '';
|
||||||
|
this.isComposing = !isKorean(lastCharacter);
|
||||||
|
},
|
||||||
handleCompositionEnd(event) {
|
handleCompositionEnd(event) {
|
||||||
this.isComposing = false;
|
if (this.isComposing) {
|
||||||
this.handleInput(event);
|
this.isComposing = false;
|
||||||
|
this.handleInput(event);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
handleInput(event) {
|
handleInput(event) {
|
||||||
// should not emit input during composition
|
// should not emit input during composition
|
||||||
|
|
Loading…
Reference in New Issue