Skip to content

Commit 26d367d

Browse files
authored
fix: fix error when pass onClear (#75)
* fix: fix error when pass onClear * test: add test case
1 parent a7392a9 commit 26d367d

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/Input.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ const Input = forwardRef<InputRef, InputProps>((props, ref) => {
214214
'htmlSize',
215215
'styles',
216216
'classNames',
217+
'onClear',
217218
],
218219
);
219220
return (

tests/index.test.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,13 +415,16 @@ describe('Input ref', () => {
415415

416416
it('support onClear', () => {
417417
const onClear = jest.fn();
418+
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
418419
const { container } = render(
419420
<Input onClear={onClear} defaultValue="test" allowClear />,
420421
);
421422
fireEvent.click(
422423
container.querySelector<HTMLSpanElement>('.rc-input-clear-icon')!,
423424
);
424425
expect(onClear).toHaveBeenCalled();
426+
expect(errorSpy).not.toHaveBeenCalled();
427+
errorSpy.mockRestore();
425428
});
426429
});
427430

0 commit comments

Comments
 (0)