-
Notifications
You must be signed in to change notification settings - Fork 638
get ActionBar axe clean #4388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
get ActionBar axe clean #4388
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@primer/react': patch | ||
--- | ||
|
||
ActionBar now produces valid HTML |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React from 'react' | ||
import {behavesAsComponent} from '../../utils/testing' | ||
import {render as HTMLRender} from '@testing-library/react' | ||
import {axe} from 'jest-axe' | ||
|
||
import ActionBar from './' | ||
import {BoldIcon, CodeIcon, ItalicIcon, LinkIcon} from '@primer/octicons-react' | ||
|
||
const SimpleActionBar = () => ( | ||
<ActionBar> | ||
<ActionBar.IconButton icon={BoldIcon} aria-label="Default"></ActionBar.IconButton> | ||
<ActionBar.IconButton icon={ItalicIcon} aria-label="Default"></ActionBar.IconButton> | ||
<ActionBar.Divider /> | ||
<ActionBar.IconButton icon={CodeIcon} aria-label="Default"></ActionBar.IconButton> | ||
<ActionBar.IconButton icon={LinkIcon} aria-label="Default"></ActionBar.IconButton> | ||
</ActionBar> | ||
) | ||
|
||
describe('ActionBar', () => { | ||
afterEach(() => { | ||
jest.clearAllMocks() | ||
}) | ||
|
||
behavesAsComponent({ | ||
Component: ActionBar, | ||
options: {skipAs: true, skipSx: true}, | ||
toRender: () => <SimpleActionBar />, | ||
}) | ||
|
||
it('should have no axe violations', async () => { | ||
const {container} = HTMLRender(<SimpleActionBar />) | ||
const results = await axe(container) | ||
expect(results).toHaveNoViolations() | ||
}) | ||
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,7 @@ export type ActionBarProps = { | |
|
||
export type ActionBarIconButtonProps = IconButtonProps | ||
|
||
const NavigationList = styled.ul` | ||
const NavigationList = styled.div` | ||
${sx}; | ||
` | ||
|
||
|
@@ -54,7 +54,7 @@ const MoreMenuListItem = styled.li` | |
height: ${MORE_BTN_HEIGHT}px; | ||
` | ||
|
||
const ulStyles = { | ||
const listStyles = { | ||
display: 'flex', | ||
listStyle: 'none', | ||
whiteSpace: 'nowrap', | ||
|
@@ -188,7 +188,7 @@ export const ActionBar: React.FC<React.PropsWithChildren<ActionBarProps>> = prop | |
}, []) | ||
|
||
const navRef = useRef<HTMLDivElement>(null) | ||
const listRef = useRef<HTMLUListElement>(null) | ||
const listRef = useRef<HTMLDivElement>(null) | ||
const moreMenuRef = useRef<HTMLLIElement>(null) | ||
const moreMenuBtnRef = useRef<HTMLButtonElement>(null) | ||
const containerRef = React.useRef<HTMLUListElement>(null) | ||
|
@@ -254,7 +254,7 @@ export const ActionBar: React.FC<React.PropsWithChildren<ActionBarProps>> = prop | |
return ( | ||
<ActionBarContext.Provider value={{size, setChildrenWidth}}> | ||
<Box ref={navRef} sx={getNavStyles()}> | ||
<NavigationList sx={ulStyles} ref={listRef} role="list"> | ||
<NavigationList sx={listStyles} ref={listRef} role="toolbar"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice, toolbar makes total sense here. I tested the arrow focusing and it looks fine to me 👍 |
||
{listItems} | ||
{menuItems.length > 0 && ( | ||
<MoreMenuListItem ref={moreMenuRef}> | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wanted to share that axe is also available in the e2e tests but with the additional github rules if that's of interest! Wasn't sure how obvious it was.