Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

fix(action): Prevent disabled buttons from being clicked or tabbed into #1004

Merged
merged 7 commits into from
Jun 1, 2020
Merged
Show file tree
Hide file tree
Changes from 6 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
14 changes: 14 additions & 0 deletions src/components/calcite-action/calcite-action.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,18 @@ describe("calcite-action", () => {
await accessible(`<calcite-action text="hello world"></calcite-action>`);
await accessible(`<calcite-action text="hello world" disabled text-enabled></calcite-action>`);
});

it("should not emit click event when disabled", async () => {
const page = await newE2EPage();

await page.setContent(`<calcite-action text="hello world" disabled></calcite-action>`);

const action = await page.find("calcite-action");

const clickSpy = await action.spyOnEvent("click");

await action.click();

expect(clickSpy).toHaveReceivedEventTimes(0);
});
});
4 changes: 4 additions & 0 deletions src/components/calcite-action/calcite-action.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
background-color: var(--calcite-app-background-clear);
}

:host([disabled]) {
driskull marked this conversation as resolved.
Show resolved Hide resolved
pointer-events: none;
}

@import "../../scss/includes/_component";

.button {
Expand Down