Skip to content

Commit

Permalink
Merge 7b5d512 into 2ca3c39
Browse files Browse the repository at this point in the history
  • Loading branch information
nedredmond authored May 16, 2024
2 parents 2ca3c39 + 7b5d512 commit 66860c3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/pink-tables-attack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/wonder-blocks-pill": minor
---

Add tabindex to pill props
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ describe("Pill", () => {
id="pill-id"
role="radio"
aria-checked="true"
tabIndex={0}
testId="pill-test-id"
onClick={() => {}}
ref={pillRef}
Expand All @@ -51,6 +52,7 @@ describe("Pill", () => {
expect(pillRef.current).toHaveAttribute("role", "radio");
expect(pillRef.current).toHaveAttribute("data-testid", "pill-test-id");
expect(pillRef.current).toHaveAttribute("aria-checked", "true");
expect(pillRef.current).toHaveAttribute("tabindex", "0");
});

test("is Clickable if onClick is passed in (mouse click)", async () => {
Expand Down
6 changes: 6 additions & 0 deletions packages/wonder-blocks-pill/src/components/pill.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ type Props = AriaProps & {
* Optional test ID for e2e testing.
*/
testId?: string;
/**
* The tab index of the pill (clickable only).
*/
tabIndex?: number;
};

const PillInner = (props: {
Expand Down Expand Up @@ -118,6 +122,7 @@ const Pill = React.forwardRef(function Pill(
onClick,
style,
testId,
tabIndex,
...ariaProps
} = props;

Expand Down Expand Up @@ -151,6 +156,7 @@ const Pill = React.forwardRef(function Pill(
style={[defaultStyles, colorStyles.clickableWrapper, style]}
testId={testId}
ref={ref as React.ForwardedRef<HTMLButtonElement>}
tabIndex={tabIndex}
{...ariaProps}
>
{() => <PillInner size={size}>{children}</PillInner>}
Expand Down

0 comments on commit 66860c3

Please sign in to comment.