From 6c05e25f239b6e39cd6946360b639360e66dc664 Mon Sep 17 00:00:00 2001 From: tanjinzhou <415800467@qq.com> Date: Fri, 15 Nov 2019 16:56:28 +0800 Subject: [PATCH] feat: input not trigger input event when chinese not complete #1281 --- components/input/Input.jsx | 6 ++++-- components/input/TextArea.jsx | 5 ++--- components/vc-calendar/src/date/DateInput.jsx | 1 + components/vc-pagination/Options.jsx | 3 ++- components/vc-pagination/Pagination.jsx | 1 + components/vc-select/Select.jsx | 1 + components/vc-time-picker/Header.jsx | 1 + components/vc-time-picker/TimePicker.jsx | 7 ------- components/vc-tree-select/src/Select.jsx | 4 +++- 9 files changed, 15 insertions(+), 14 deletions(-) diff --git a/components/input/Input.jsx b/components/input/Input.jsx index b598cafbc..24ddf1fe0 100644 --- a/components/input/Input.jsx +++ b/components/input/Input.jsx @@ -124,6 +124,7 @@ export default { }, handleChange(e) { + if (e.target.composing) return; this.setValue(e.target.value, e); }, @@ -237,6 +238,7 @@ export default { ]); const { stateValue, getInputClassName, handleKeyDown, handleChange, $listeners } = this; const inputProps = { + directives: [{ name: 'ant-input' }], domProps: { value: fixControlledValue(stateValue), }, @@ -251,7 +253,6 @@ export default { ref: 'input', key: 'ant-input', }; - inputProps.directives = [{ name: 'ant-input' }]; return this.renderLabeledIcon(prefixCls, ); }, }, @@ -263,8 +264,9 @@ export default { attrs: this.$attrs, on: { ...$listeners, - change: this.handleChange, + input: this.handleChange, keydown: this.handleKeyDown, + change: noop, }, directives: [ { diff --git a/components/input/TextArea.jsx b/components/input/TextArea.jsx index 1b42e399c..4ff2c40d7 100644 --- a/components/input/TextArea.jsx +++ b/components/input/TextArea.jsx @@ -116,6 +116,7 @@ export default { }, handleTextareaChange(e) { + if (e.target.composing) return; if (!hasProp(this, 'value')) { this.stateValue = e.target.value; this.resizeTextarea(); @@ -163,6 +164,7 @@ export default { }); const textareaProps = { + directives: [{ name: 'ant-input' }], attrs: { ...otherProps, ...$attrs }, on: { ...$listeners, @@ -171,9 +173,6 @@ export default { change: noop, }, }; - if ($listeners['change.value']) { - textareaProps.directives = [{ name: 'ant-input' }]; - } return (