Skip to content

Commit be8f901

Browse files
authored
ActionList: a11y fixes (#1958)
* role=none without a parent role is invalid * Add example with Heading * Add focus styles for high contrast mode * Create actionlist-a11y-fixes.md
1 parent 26c7784 commit be8f901

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@primer/react": patch
3+
---
4+
5+
ActionList: Add focus styles for Windows high contrast mode
6+
ActionList: Fix incorrect role for ActionList.Group outside ActionMenu

src/ActionList/Group.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export const Group: React.FC<ActionListGroupProps> = ({
5050
return (
5151
<Box
5252
as="li"
53-
role="none"
53+
role={listRole ? 'none' : undefined}
5454
sx={{
5555
'&:not(:first-child)': {marginTop: 2},
5656
listStyle: 'none', // hide the ::marker inserted by browser's stylesheet

src/ActionList/Item.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,14 @@ export const Item = React.forwardRef<HTMLLIElement, ActionListItemProps>(
159159
}
160160
},
161161

162+
'@media (forced-colors: active)': {
163+
':focus': {
164+
// we set color to be transparent and let the high contrast rules
165+
// decide what color with contrast should that be corrected to
166+
outline: 'solid 1px transparent !important'
167+
}
168+
},
169+
162170
/** Divider styles */
163171
'[data-component="ActionList.Item--DividerContainer"]': {
164172
position: 'relative'

src/stories/ActionList/examples.stories.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
XIcon
1616
} from '@primer/octicons-react'
1717

18-
import {ThemeProvider} from '../..'
18+
import {Heading, ThemeProvider} from '../..'
1919
import {ActionList} from '../../ActionList'
2020
import BaseStyles from '../../BaseStyles'
2121
import Avatar from '../../Avatar'
@@ -49,9 +49,16 @@ export function WithLinks(): JSX.Element {
4949
<>
5050
<h1>With Links</h1>
5151

52-
<p>This pattern can be seen in the repository sidebar, containing a list of links</p>
52+
<p>This pattern can be seen in the repository sidebar, containing a list of links. </p>
53+
<p>
54+
The heading &quot;Details&quot; is outside the ActionList and needs to have an <code>id</code> which is passed
55+
to ActionList with <code>aria-labelledby</code>.
56+
</p>
5357

54-
<ActionList>
58+
<Heading as="h1" id="list-heading" sx={{fontSize: 1}}>
59+
Details
60+
</Heading>
61+
<ActionList aria-labelledby="list-heading">
5562
<ActionList.LinkItem href="https://github.com/primer/react#readme">
5663
<ActionList.LeadingVisual>
5764
<BookIcon />

0 commit comments

Comments
 (0)