mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 22:36:31 +08:00
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:
parent
74d81c2d07
commit
b52053051c
@ -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"
|
||||
>
|
||||
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user