@@ -39,6 +39,7 @@ export default {
39
39
const { value, defaultValue } = this . $props ;
40
40
return {
41
41
stateValue : ! hasProp ( this , 'value' ) ? defaultValue : value ,
42
+ isComposing : false
42
43
} ;
43
44
} ,
44
45
watch : {
@@ -83,6 +84,9 @@ export default {
83
84
} ,
84
85
85
86
setValue ( value , e ) {
87
+ if ( this . isComposing ) {
88
+ return ;
89
+ }
86
90
// https://github.com/vueComponent/ant-design-vue/issues/92
87
91
if ( isIE && ! isIE9 && this . stateValue === value ) {
88
92
return ;
@@ -121,7 +125,14 @@ export default {
121
125
handleChange ( e ) {
122
126
this . setValue ( e . target . value , e ) ;
123
127
} ,
124
-
128
+ handleComposition ( e ) {
129
+ if ( e . type === 'compositionstart' ) {
130
+ this . isComposing = true ;
131
+ } else if ( e . type === 'compositionend' ) {
132
+ this . isComposing = false ;
133
+ this . handleChange ( e ) ;
134
+ }
135
+ } ,
125
136
renderClearIcon ( prefixCls ) {
126
137
const { allowClear } = this . $props ;
127
138
const { stateValue } = this ;
@@ -224,7 +235,7 @@ export default {
224
235
'value' ,
225
236
'defaultValue' ,
226
237
] ) ;
227
- const { stateValue, getInputClassName, handleKeyDown, handleChange, $listeners } = this ;
238
+ const { stateValue, getInputClassName, handleKeyDown, handleChange, handleComposition , $listeners } = this ;
228
239
const inputProps = {
229
240
domProps : {
230
241
value : fixControlledValue ( stateValue ) ,
@@ -235,6 +246,8 @@ export default {
235
246
keydown : handleKeyDown ,
236
247
input : handleChange ,
237
248
change : noop ,
249
+ compositionstart : handleComposition ,
250
+ compositionend : handleComposition
238
251
} ,
239
252
class : getInputClassName ( prefixCls ) ,
240
253
ref : 'input' ,
@@ -248,14 +261,16 @@ export default {
248
261
} ,
249
262
render ( ) {
250
263
if ( this . $props . type === 'textarea' ) {
251
- const { $listeners } = this ;
264
+ const { $listeners, handleChange , handleKeyDown , handleComposition } = this ;
252
265
const textareaProps = {
253
266
props : this . $props ,
254
267
attrs : this . $attrs ,
255
268
on : {
256
269
...$listeners ,
257
- change : this . handleChange ,
258
- keydown : this . handleKeyDown ,
270
+ change : handleChange ,
271
+ keydown : handleKeyDown ,
272
+ compositionstart : handleComposition ,
273
+ compositionend : handleComposition
259
274
} ,
260
275
directives : [
261
276
{
0 commit comments