diff --git a/components/input/Input.tsx b/components/input/Input.tsx index e00382a016..10106e1877 100644 --- a/components/input/Input.tsx +++ b/components/input/Input.tsx @@ -142,9 +142,10 @@ class Input extends React.Component { setValue( value: string, e: React.ChangeEvent | React.MouseEvent, + callback?: () => void, ) { if (!('value' in this.props)) { - this.setState({ value }); + this.setState({ value }, callback); } const { onChange } = this.props; if (onChange) { @@ -167,7 +168,9 @@ class Input extends React.Component { } handleReset = (e: React.MouseEvent) => { - this.setValue('', e); + this.setValue('', e, () => { + this.focus(); + }); }; handleChange = (e: React.ChangeEvent) => { diff --git a/components/input/Password.tsx b/components/input/Password.tsx index a60f7e51d7..a8aedfadbc 100644 --- a/components/input/Password.tsx +++ b/components/input/Password.tsx @@ -39,15 +39,18 @@ export default class Password extends React.Component, - ); + const iconProps = { + [iconTrigger]: this.onChange, + className: `${prefixCls}-icon`, + type: this.state.visible ? 'eye-invisible' : 'eye', + key: 'passwordIcon', + onMouseDown: (e: MouseEvent) => { + // Prevent focused state lost + // https://github.com/ant-design/ant-design/issues/15173 + e.preventDefault(); + }, + }; + return ; } render() { diff --git a/components/input/__tests__/__snapshots__/demo.test.js.snap b/components/input/__tests__/__snapshots__/demo.test.js.snap index 8eb1584ac1..0fb2f77ecb 100644 --- a/components/input/__tests__/__snapshots__/demo.test.js.snap +++ b/components/input/__tests__/__snapshots__/demo.test.js.snap @@ -494,6 +494,7 @@ exports[`renders ./components/input/demo/group.md correctly 1`] = ` />