Skip to content

Commit

Permalink
Merge pull request #1208 from gsoft-inc/fix-icon-button-loading-aria-…
Browse files Browse the repository at this point in the history
…label-missing

fix: missing aria-label on loading IconButton
  • Loading branch information
tjosepo committed Apr 10, 2023
2 parents 268fca9 + bef25c8 commit 01c5617
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/rare-eyes-fly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@orbit-ui/components": patch
---

Fix missing aria-label on IconButton's Spinner when loading is true
1 change: 1 addition & 0 deletions packages/components/src/button/src/IconButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export function InnerIconButton(props: InnerIconButtonProps) {

const loadingMarkup = loading && (
<Spinner
aria-label="Loading..."
className="o-ui-button-spinner"
color={variant === "primary" ? "alias-static-white" : undefined}
role="presentation"
Expand Down
17 changes: 17 additions & 0 deletions packages/components/src/button/tests/jest/IconButton.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,23 @@ test("when loading is true, the button should prevent onClick", async () => {
await waitFor(() => expect(handler).not.toHaveBeenCalled());
});

// ***** Aria *****

test("when loading is true, the spinner should have an aria-label", async () => {
renderWithTheme(
<IconButton
loading
aria-label="Add"
>
<AddMajorIcon />
</IconButton>
);

const spinner = screen.getByRole("presentation");

expect(spinner).toHaveAttribute("aria-label");
});

// ***** Api *****

test("can focus the button with the focus api", async () => {
Expand Down

0 comments on commit 01c5617

Please sign in to comment.