mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-11-30 02:59:04 +08:00
This commit is contained in:
parent
5ef12dfaa5
commit
3c96997210
@ -75,7 +75,7 @@ const Search = React.forwardRef<InputRef, SearchProps>((props, ref) => {
|
||||
};
|
||||
|
||||
const onPressEnter = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
||||
if (composedRef.current) {
|
||||
if (composedRef.current || loading) {
|
||||
return;
|
||||
}
|
||||
onSearch(e);
|
||||
|
@ -161,6 +161,15 @@ describe('Input.Search', () => {
|
||||
expect(asFragmentWithEnterButton().firstChild).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should not trigger onSearch when press enter while loading', () => {
|
||||
const onSearch = jest.fn();
|
||||
const { container } = render(
|
||||
<Search loading onSearch={onSearch} />,
|
||||
);
|
||||
fireEvent.keyDown(container.querySelector('input')!, { key: 'Enter', keyCode: 13 });
|
||||
expect(onSearch).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should support addonAfter and suffix for loading', () => {
|
||||
const { asFragment } = render(<Search loading suffix="suffix" addonAfter="addonAfter" />);
|
||||
const { asFragment: asFragmentWithEnterButton } = render(
|
||||
|
Loading…
Reference in New Issue
Block a user