Skip to content

Commit

Permalink
Add aria-selected value to ActionList.Item. (#3579)
Browse files Browse the repository at this point in the history
* Add aria-selected value to ActionList.Item.

* Create late-bugs-battle.md

* Conditionally set aria-selected if role is option.

* Linting and formatting.

* Update src/ActionList/Item.tsx

Co-authored-by: Josh Black <joshblack@github.com>

* Update test so aria-selected gets generated correctly.

---------

Co-authored-by: Josh Black <joshblack@github.com>
  • Loading branch information
radglob and joshblack authored Aug 16, 2023
1 parent 3bb6dc8 commit 66482a7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .changeset/late-bugs-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@primer/react": patch
---

Add aria-selected value to ActionList.Item.

<!-- Changed components: ActionList -->
1 change: 1 addition & 0 deletions src/ActionList/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ export const Item = React.forwardRef<HTMLLIElement, ActionListItemProps>(
ref={forwardedRef}
sx={merge<BetterSystemStyleObject>(styles, sxProp)}
data-variant={variant === 'danger' ? variant : undefined}
aria-selected={containerProps.role === 'option' ? selected : undefined}
{...containerProps}
{...props}
>
Expand Down
1 change: 0 additions & 1 deletion src/__tests__/ActionList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ function SingleSelectListStory(): JSX.Element {
key={index}
role="option"
selected={index === selectedIndex}
aria-selected={index === selectedIndex}
onSelect={() => setSelectedIndex(index)}
disabled={project.disabled}
>
Expand Down

0 comments on commit 66482a7

Please sign in to comment.