Skip to content

Commit bd6b6be

Browse files
author
潕量
authored
fix(Input): eye close/open, close #2193
1 parent be38adb commit bd6b6be

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/input/password.jsx

+4-10
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function preventDefault(e) {
99
}
1010
export default class Password extends Input {
1111
state = {
12-
hint: 'eye',
12+
hint: 'eye-close',
1313
htmlType: 'password',
1414
};
1515

@@ -30,10 +30,10 @@ export default class Password extends Input {
3030
toggleEye = e => {
3131
e.preventDefault();
3232

33-
const eyeClose = this.state.hint === 'eye-close';
33+
const eyeClose = this.state.hint === 'eye';
3434

3535
this.setState({
36-
hint: eyeClose ? 'eye' : 'eye-close',
36+
hint: eyeClose ? 'eye-close' : 'eye',
3737
htmlType: eyeClose || !this.props.showToggle ? 'password' : 'text',
3838
});
3939
};
@@ -42,13 +42,7 @@ export default class Password extends Input {
4242
const { showToggle, ...others } = this.props;
4343
const { hint, htmlType } = this.state;
4444

45-
const extra = showToggle ? (
46-
<Icon
47-
type={hint}
48-
onClick={this.toggleEye}
49-
onMouseDown={preventDefault}
50-
/>
51-
) : null;
45+
const extra = showToggle ? <Icon type={hint} onClick={this.toggleEye} onMouseDown={preventDefault} /> : null;
5246

5347
return <Input {...others} extra={extra} htmlType={htmlType} />;
5448
}

0 commit comments

Comments
 (0)