Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/button/__tests__/button.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ describe('Button Component', () => {
expect(onClick.mock.calls.length).toBe(0);
});

test("onClick doesn't fire on a disabled anchor button", () => {
const onClick = jest.fn();
const { container } = render(
<Button href="https://example.com" disabled onClick={onClick}>
link
</Button>
);
const anchor = container.querySelector('a');
if (anchor) fireEvent.click(anchor);
expect(onClick.mock.calls.length).toBe(0);
});

test('simulate isLoading with google translate does not throw with element child', () => {
const { rerender, container } = render(
<Button isLoading={false}>
Expand Down
4 changes: 2 additions & 2 deletions src/button/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class Button extends React.Component<

// @ts-ignore
internalOnClick = (...args) => {
const { isLoading, onClick } = this.props;
if (isLoading) {
const { isLoading, disabled, onClick } = this.props;
if (isLoading || disabled) {
args[0].preventDefault();
return;
}
Expand Down