Skip to content

fix: Input box does not need to be verified until Chinese input is co… #1281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions components/input/Input.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default {
const { value, defaultValue } = this.$props;
return {
stateValue: !hasProp(this, 'value') ? defaultValue : value,
isComposing: false
};
},
watch: {
Expand Down Expand Up @@ -83,6 +84,9 @@ export default {
},

setValue(value, e) {
if (this.isComposing) {
return;
}
// https://github.com/vueComponent/ant-design-vue/issues/92
if (isIE && !isIE9 && this.stateValue === value) {
return;
Expand Down Expand Up @@ -121,7 +125,14 @@ export default {
handleChange(e) {
this.setValue(e.target.value, e);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handleChange(e) {
      if (!e.target.composing) {
        this.setValue(e.target.value, e);
      }
    },

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

其他就不要更改了吧

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的,改了

},

handleComposition(e) {
if (e.type === 'compositionstart') {
this.isComposing = true;
}else if (e.type === 'compositionend') {
this.isComposing = false;
this.handleChange(e);
}
},
renderClearIcon(prefixCls) {
const { allowClear } = this.$props;
const { stateValue } = this;
Expand Down Expand Up @@ -224,7 +235,7 @@ export default {
'value',
'defaultValue',
]);
const { stateValue, getInputClassName, handleKeyDown, handleChange, $listeners } = this;
const { stateValue, getInputClassName, handleKeyDown, handleChange, handleComposition, $listeners } = this;
const inputProps = {
domProps: {
value: fixControlledValue(stateValue),
Expand All @@ -235,6 +246,8 @@ export default {
keydown: handleKeyDown,
input: handleChange,
change: noop,
compositionstart: handleComposition,
compositionend: handleComposition
},
class: getInputClassName(prefixCls),
ref: 'input',
Expand All @@ -248,14 +261,16 @@ export default {
},
render() {
if (this.$props.type === 'textarea') {
const { $listeners } = this;
const { $listeners, handleChange, handleKeyDown, handleComposition } = this;
const textareaProps = {
props: this.$props,
attrs: this.$attrs,
on: {
...$listeners,
change: this.handleChange,
keydown: this.handleKeyDown,
change: handleChange,
keydown: handleKeyDown,
compositionstart: handleComposition,
compositionend: handleComposition
},
directives: [
{
Expand Down