Input.Search should disable enter button when disabled prop is true (#10051)

* Input Search should disable enter button when disabled prop is true, close #10040

* test: Add test case for commit bd21722
This commit is contained in:
诸岳 2018-04-15 13:14:26 +08:00 committed by 偏右
parent 74d81c2d07
commit b52053051c
2 changed files with 9 additions and 1 deletions

View File

@ -40,7 +40,7 @@ export default class Search extends React.Component<SearchProps, any> {
}
getButtonOrIcon() {
const { enterButton, prefixCls, size } = this.props;
const { enterButton, prefixCls, size, disabled } = this.props;
if (!enterButton) {
return <Icon className={`${prefixCls}-icon`} type="search" key="searchIcon" />;
}
@ -59,6 +59,7 @@ export default class Search extends React.Component<SearchProps, any> {
className={`${prefixCls}-button`}
type="primary"
size={size}
disabled={disabled}
onClick={this.onSearch}
key="enterButton"
>

View File

@ -20,4 +20,11 @@ describe('Input.Search', () => {
);
expect(wrapper.render()).toMatchSnapshot();
});
it('should disable enter button when disabled prop is true', () => {
const wrapper = mount(
<Search placeholder="input search text" enterButton disabled />
);
expect(wrapper.find('.ant-btn-primary[disabled]')).toHaveLength(1);
});
});