mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-01 11:39:28 +08:00
parent
cf401f73c8
commit
4be9535926
@ -190,7 +190,7 @@ class Input extends React.Component<InputProps, InputState> {
|
||||
|
||||
onFocus: React.FocusEventHandler<HTMLInputElement> = e => {
|
||||
const { onFocus } = this.props;
|
||||
this.setState({ focused: true });
|
||||
this.setState({ focused: true }, this.clearPasswordValueAttribute);
|
||||
if (onFocus) {
|
||||
onFocus(e);
|
||||
}
|
||||
@ -198,7 +198,7 @@ class Input extends React.Component<InputProps, InputState> {
|
||||
|
||||
onBlur: React.FocusEventHandler<HTMLInputElement> = e => {
|
||||
const { onBlur } = this.props;
|
||||
this.setState({ focused: false });
|
||||
this.setState({ focused: false }, this.clearPasswordValueAttribute);
|
||||
if (onBlur) {
|
||||
onBlur(e);
|
||||
}
|
||||
|
@ -70,6 +70,23 @@ describe('Input.Password', () => {
|
||||
expect(wrapper.find('input').at('0').getDOMNode().getAttribute('value')).toBeFalsy();
|
||||
});
|
||||
|
||||
// https://github.com/ant-design/ant-design/issues/24526
|
||||
it('should not show value attribute in input element after blur it', async () => {
|
||||
const wrapper = mount(<Input.Password />);
|
||||
wrapper
|
||||
.find('input')
|
||||
.at('0')
|
||||
.simulate('change', { target: { value: 'value' } });
|
||||
await sleep();
|
||||
expect(wrapper.find('input').at('0').getDOMNode().getAttribute('value')).toBeFalsy();
|
||||
wrapper.find('input').at('0').simulate('blur');
|
||||
await sleep();
|
||||
expect(wrapper.find('input').at('0').getDOMNode().getAttribute('value')).toBeFalsy();
|
||||
wrapper.find('input').at('0').simulate('focus');
|
||||
await sleep();
|
||||
expect(wrapper.find('input').at('0').getDOMNode().getAttribute('value')).toBeFalsy();
|
||||
});
|
||||
|
||||
// https://github.com/ant-design/ant-design/issues/20541
|
||||
it('could be unmount without errors', () => {
|
||||
expect(() => {
|
||||
|
Loading…
Reference in New Issue
Block a user