mirror of https://github.com/ElemeFE/element
Input / Select: fix Korean IME composition bug (#10648)
* Input: fix cursor goes to the end of the text(#10611) * Input: fix cursor goes to the end of the text(#10611) * Update input.vue * Update select.vue * Update input.vuepull/10716/head
parent
769db14516
commit
783cb2691f
|
@ -100,6 +100,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',
|
||||
|
@ -255,7 +256,9 @@
|
|||
this.isOnComposition = false;
|
||||
this.handleInput(event);
|
||||
} else {
|
||||
this.isOnComposition = true;
|
||||
const text = event.target.value;
|
||||
const lastCharacter = text[text.length - 1] || '';
|
||||
this.isOnComposition = !isKorean(lastCharacter);
|
||||
}
|
||||
},
|
||||
handleInput(event) {
|
||||
|
|
|
@ -147,6 +147,7 @@
|
|||
import { getValueByPath } from 'element-ui/src/utils/util';
|
||||
import { valueEquals } from 'element-ui/src/utils/util';
|
||||
import NavigationMixin from './navigation-mixin';
|
||||
import { isKorean } from 'element-ui/src/utils/shared';
|
||||
|
||||
const sizeMap = {
|
||||
'medium': 36,
|
||||
|
@ -412,11 +413,13 @@
|
|||
|
||||
methods: {
|
||||
handleComposition(event) {
|
||||
const text = event.target.value;
|
||||
if (event.type === 'compositionend') {
|
||||
this.isOnComposition = false;
|
||||
this.handleQueryChange(event.target.value);
|
||||
this.handleQueryChange(text);
|
||||
} else {
|
||||
this.isOnComposition = true;
|
||||
const lastCharacter = text[text.length - 1] || '';
|
||||
this.isOnComposition = !isKorean(lastCharacter);
|
||||
}
|
||||
},
|
||||
handleQueryChange(val) {
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
export function isDef(val) {
|
||||
return val !== undefined && val !== null;
|
||||
}
|
||||
export function isKorean(text) {
|
||||
const reg = /([(\uAC00-\uD7AF)|(\u3130-\u318F)])+/gi;
|
||||
return reg.test(text);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue