Skip to content

Commit

Permalink
fix: event miss type
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed May 10, 2023
1 parent cfdcf03 commit 8a16023
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export const Checkbox = forwardRef<CheckboxRef, CheckboxProps>((props, ref) => {
onChange?.({
target: {
...props,
type,
checked: e.target.checked,
},
stopPropagation() {
Expand Down
5 changes: 5 additions & 0 deletions tests/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ describe('rc-checkbox', () => {
fireEvent.click(inputEl);

expect(onChange).toHaveBeenCalledTimes(1);
expect(onChange).toHaveBeenCalledWith(
expect.objectContaining({
target: expect.objectContaining({ type: 'checkbox', checked: true }),
}),
);
expect(inputEl.checked).toBe(true);
});

Expand Down

0 comments on commit 8a16023

Please sign in to comment.