二货机器人
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
12 additions and
0 deletions
-
components/input/Input.tsx
-
components/input/__tests__/focus.test.tsx
|
|
@ -188,6 +188,9 @@ class Input extends React.Component<InputProps, InputState> { |
|
|
|
if (nextProps.value !== undefined || prevValue !== nextProps.value) { |
|
|
|
newState.value = nextProps.value; |
|
|
|
} |
|
|
|
if (nextProps.disabled) { |
|
|
|
newState.focused = false; |
|
|
|
} |
|
|
|
return newState; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -55,4 +55,13 @@ describe('Input.Focus', () => { |
|
|
|
expect(focus).toHaveBeenCalled(); |
|
|
|
expect(setSelectionRange).toHaveBeenCalledWith(expect.anything(), 0, 5); |
|
|
|
}); |
|
|
|
|
|
|
|
it('disabled should reset focus', () => { |
|
|
|
const wrapper = mount(<Input allowClear />); |
|
|
|
wrapper.find('input').simulate('focus'); |
|
|
|
expect(wrapper.exists('.ant-input-affix-wrapper-focused')).toBeTruthy(); |
|
|
|
|
|
|
|
wrapper.setProps({ disabled: true }); |
|
|
|
expect(wrapper.exists('.ant-input-affix-wrapper-focused')).toBeFalsy(); |
|
|
|
}); |
|
|
|
}); |
|
|
|