Skip to content

Commit

Permalink
fix(tab): pass event to onclick handler
Browse files Browse the repository at this point in the history
pass event as first argument, and value as second argument to onclick handler
  • Loading branch information
arturbien committed Apr 11, 2020
1 parent 92bd22e commit d372912
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/Tab/Tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const Tab = React.forwardRef(function Tab(props, ref) {
<StyledTab
selected={selected}
aria-selected={selected}
onClick={() => onClick(value)}
onClick={e => onClick(e, value)}
role='tab'
ref={ref}
{...otherProps}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Tabs/Tabs.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('<Tabs />', () => {

fireEvent.click(getAllByRole('tab')[1]);
expect(handleChange).toBeCalledTimes(1);
expect(handleChange).toHaveBeenCalledWith(1);
expect(handleChange.mock.calls[0][1]).toBe(1);
});
});
});
2 changes: 1 addition & 1 deletion src/components/Tabs/Tabs.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const Default = () => {
activeTab: 0
});

const handleChange = value => setState({ activeTab: value });
const handleChange = (e, value) => setState({ activeTab: value });

const { activeTab } = state;
return (
Expand Down

0 comments on commit d372912

Please sign in to comment.