Skip to content

Commit 302ad47

Browse files
keithamuslukasoppermann
authored andcommitted
get ActionBar axe clean (#4388)
* get ActionBar axe clean * changeset * fix type * fix type
1 parent fbc1b11 commit 302ad47

File tree

3 files changed

+44
-4
lines changed

3 files changed

+44
-4
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react': patch
3+
---
4+
5+
ActionBar now produces valid HTML
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React from 'react'
2+
import {behavesAsComponent} from '../../utils/testing'
3+
import {render as HTMLRender} from '@testing-library/react'
4+
import {axe} from 'jest-axe'
5+
6+
import ActionBar from './'
7+
import {BoldIcon, CodeIcon, ItalicIcon, LinkIcon} from '@primer/octicons-react'
8+
9+
const SimpleActionBar = () => (
10+
<ActionBar>
11+
<ActionBar.IconButton icon={BoldIcon} aria-label="Default"></ActionBar.IconButton>
12+
<ActionBar.IconButton icon={ItalicIcon} aria-label="Default"></ActionBar.IconButton>
13+
<ActionBar.Divider />
14+
<ActionBar.IconButton icon={CodeIcon} aria-label="Default"></ActionBar.IconButton>
15+
<ActionBar.IconButton icon={LinkIcon} aria-label="Default"></ActionBar.IconButton>
16+
</ActionBar>
17+
)
18+
19+
describe('ActionBar', () => {
20+
afterEach(() => {
21+
jest.clearAllMocks()
22+
})
23+
24+
behavesAsComponent({
25+
Component: ActionBar,
26+
options: {skipAs: true, skipSx: true},
27+
toRender: () => <SimpleActionBar />,
28+
})
29+
30+
it('should have no axe violations', async () => {
31+
const {container} = HTMLRender(<SimpleActionBar />)
32+
const results = await axe(container)
33+
expect(results).toHaveNoViolations()
34+
})
35+
})

packages/react/src/drafts/ActionBar/ActionBar.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export type ActionBarProps = {
4242

4343
export type ActionBarIconButtonProps = IconButtonProps
4444

45-
const NavigationList = styled.ul`
45+
const NavigationList = styled.div`
4646
${sx};
4747
`
4848

@@ -54,7 +54,7 @@ const MoreMenuListItem = styled.li`
5454
height: ${MORE_BTN_HEIGHT}px;
5555
`
5656

57-
const ulStyles = {
57+
const listStyles = {
5858
display: 'flex',
5959
listStyle: 'none',
6060
whiteSpace: 'nowrap',
@@ -188,7 +188,7 @@ export const ActionBar: React.FC<React.PropsWithChildren<ActionBarProps>> = prop
188188
}, [])
189189

190190
const navRef = useRef<HTMLDivElement>(null)
191-
const listRef = useRef<HTMLUListElement>(null)
191+
const listRef = useRef<HTMLDivElement>(null)
192192
const moreMenuRef = useRef<HTMLLIElement>(null)
193193
const moreMenuBtnRef = useRef<HTMLButtonElement>(null)
194194
const containerRef = React.useRef<HTMLUListElement>(null)
@@ -254,7 +254,7 @@ export const ActionBar: React.FC<React.PropsWithChildren<ActionBarProps>> = prop
254254
return (
255255
<ActionBarContext.Provider value={{size, setChildrenWidth}}>
256256
<Box ref={navRef} sx={getNavStyles()}>
257-
<NavigationList sx={ulStyles} ref={listRef} role="list">
257+
<NavigationList sx={listStyles} ref={listRef} role="toolbar">
258258
{listItems}
259259
{menuItems.length > 0 && (
260260
<MoreMenuListItem ref={moreMenuRef}>

0 commit comments

Comments
 (0)