Skip to content

Commit f6b7808

Browse files
authored
fix(buttons): fix onClick bug (#1118)
1 parent 462f8f5 commit f6b7808

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/components/buttons/accessible-button/accessible-button.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const AccessibleButton = React.forwardRef((props, ref) => {
88

99
const handleClick = React.useCallback(
1010
event => {
11-
if (!props.isDisabled) return onClick(event);
11+
if (!props.isDisabled && onClick) return onClick(event);
1212
// eslint-disable-next-line no-useless-return, consistent-return
1313
return;
1414
},

src/components/buttons/secondary-button/secondary-button.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ describe('rendering', () => {
7373
describe('when using "linkTo"', () => {
7474
it('should navigate to link when clicked', async () => {
7575
const { getByLabelText, history } = render(
76-
<SecondaryButton {...props} linkTo="/foo/bar" />
76+
<SecondaryButton {...props} onClick={null} linkTo="/foo/bar" />
7777
);
7878
fireEvent.click(getByLabelText('Add'));
7979
await wait(() => {

0 commit comments

Comments
 (0)