Skip to content

Commit

Permalink
AnchoredOverlay: Keep tabIndex for renderAnchor (primer#2159)
Browse files Browse the repository at this point in the history
* Revert "remove tabIndex from AnchoredOverlay"

This reverts commit e7f2d03.

* remove change from changelog as well

* update matching snapshots
  • Loading branch information
siddharthkp authored and PrinceSumberia committed Aug 1, 2022
1 parent 8506cfc commit 738d587
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 5 deletions.
7 changes: 2 additions & 5 deletions .changeset/anchored-overlay-clever-mails-roll.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
---
"@primer/react": patch
'@primer/react': patch
---

AnchoredOverlay accessibility fixes
- `aria-expanded` attribute is removed from anchor when overlay is not open
- `tabIndex=0` is removed from anchor because it should only be used with interactive elements

AnchoredOverlay: `aria-expanded` attribute is removed from anchor when overlay is not open
1 change: 1 addition & 0 deletions src/AnchoredOverlay/AnchoredOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export const AnchoredOverlay: React.FC<AnchoredOverlayProps> = ({
id: anchorId,
'aria-haspopup': 'true',
'aria-expanded': open ? 'true' : undefined,
tabIndex: 0,
onClick: onAnchorClick,
onKeyDown: onAnchorKeyDown
})}
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/__snapshots__/ActionMenu.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ exports[`ActionMenu renders consistently 1`] = `
id="react-aria-1"
onClick={[Function]}
onKeyDown={[Function]}
tabIndex={0}
type="button"
>
<span
Expand Down
2 changes: 2 additions & 0 deletions src/__tests__/__snapshots__/AnchoredOverlay.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ exports[`AnchoredOverlay renders consistently 1`] = `
id="react-aria-1"
onClick={[Function]}
onKeyDown={[Function]}
tabIndex={0}
>
Anchor Button
</button>
Expand Down Expand Up @@ -201,6 +202,7 @@ exports[`AnchoredOverlay should render consistently when open 1`] = `
aria-haspopup="true"
class="c1"
id="react-aria-1"
tabindex="0"
>
Anchor Button
</button>
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/__snapshots__/SelectPanel.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ exports[`SelectPanel renders consistently 1`] = `
id="react-aria-1"
onClick={[Function]}
onKeyDown={[Function]}
tabIndex={0}
type="button"
>
Select Items
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,6 @@ exports[`ActionMenu renders consistently 1`] = `
id="react-aria-1"
onClick={[Function]}
onKeyDown={[Function]}
tabIndex={0}
/>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ exports[`DropdownMenu renders consistently 1`] = `
id="react-aria-1"
onClick={[Function]}
onKeyDown={[Function]}
tabIndex={0}
type="button"
>
<svg
Expand Down

0 comments on commit 738d587

Please sign in to comment.