🐛 Input disabled should not be allowed to clear (#18482)

close #18481
This commit is contained in:
偏右 2019-08-26 22:58:00 +08:00 committed by GitHub
parent 7e9cc07059
commit 26c61a12d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -180,9 +180,9 @@ class Input extends React.Component<InputProps, any> {
}
renderClearIcon(prefixCls: string) {
const { allowClear } = this.props;
const { allowClear, disabled } = this.props;
const { value } = this.state;
if (!allowClear || value === undefined || value === null || value === '') {
if (!allowClear || disabled || value === undefined || value === null || value === '') {
return null;
}
return (

View File

@ -308,4 +308,9 @@ describe('Input allowClear', () => {
.getDOMNode(),
);
});
it('should not support allowClear when it is disabled', () => {
const wrapper = mount(<Input allowClear defaultValue="111" disabled />);
expect(wrapper.find('.ant-input-clear-icon').length).toBe(0);
});
});