Browse Source
fix: prevent Search component to throw passing null as enterButton (#27591)
pull/27600/head
Davide Bianchi
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
7 additions and
1 deletions
-
components/input/Search.tsx
-
components/input/__tests__/Search.test.js
|
|
@ -56,7 +56,7 @@ const Search = React.forwardRef<Input, SearchProps>((props, ref) => { |
|
|
|
const btnClassName = `${prefixCls}-button`; |
|
|
|
|
|
|
|
let button: React.ReactNode; |
|
|
|
const enterButtonAsElement = enterButton as React.ReactElement; |
|
|
|
const enterButtonAsElement = (enterButton || {}) as React.ReactElement; |
|
|
|
const isAntdButton = |
|
|
|
enterButtonAsElement.type && |
|
|
|
(enterButtonAsElement.type as typeof Button).__ANT_BUTTON === true; |
|
|
|
|
|
@ -21,6 +21,12 @@ describe('Input.Search', () => { |
|
|
|
expect(wrapper.render()).toMatchSnapshot(); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should support enterButton null', () => { |
|
|
|
expect(() => { |
|
|
|
mount(<Search enterButton={null} />); |
|
|
|
}).not.toThrow(); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should support ReactNode suffix without error', () => { |
|
|
|
const wrapper = mount(<Search suffix={<div>ok</div>} />); |
|
|
|
expect(wrapper.render()).toMatchSnapshot(); |
|
|
|