-
Notifications
You must be signed in to change notification settings - Fork 536
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
PageLayout: Use HTML5 landmark elements #1973
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
89dabaf
Use HTML5 landmark elements
colebemis dbc9f0b
Remove separator role
colebemis 3d3511d
Create brown-maps-yawn.md
colebemis 6637d4f
Update snapshot tests
colebemis 31f105e
Update component checklist
colebemis c30240e
Merge branch 'page-layout-a11y' of github.com:primer/react into page-…
colebemis 8106309
Merge branch 'main' into page-layout-a11y
colebemis 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 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 | ||
--- | ||
|
||
The `PageLayout` component now renders [HTML5 landmark elements](https://web.dev/use-landmarks/) (`header`, `aside`, `footer`) to improve the navigation experience for people using assistive technologies (like screen readers) |
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -114,7 +114,6 @@ const HorizontalDivider: React.FC<DividerProps> = ({variant = 'none', variantWhe | |
const {padding} = React.useContext(PageLayoutContext) | ||
return ( | ||
<Box | ||
role="separator" | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
sx={(theme: any) => | ||
merge<BetterSystemStyleObject>( | ||
|
@@ -156,7 +155,6 @@ const verticalDividerVariants = { | |
const VerticalDivider: React.FC<DividerProps> = ({variant = 'none', variantWhenNarrow = 'inherit', sx = {}}) => { | ||
return ( | ||
<Box | ||
role="separator" | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
sx={(theme: any) => | ||
merge<BetterSystemStyleObject>( | ||
|
@@ -191,6 +189,7 @@ const Header: React.FC<PageLayoutHeaderProps> = ({ | |
const {rowGap} = React.useContext(PageLayoutContext) | ||
return ( | ||
<Box | ||
as="header" | ||
sx={merge<BetterSystemStyleObject>( | ||
{ | ||
order: REGION_ORDER.header, | ||
|
@@ -230,6 +229,7 @@ const contentWidths = { | |
const Content: React.FC<PageLayoutContentProps> = ({width = 'full', children, sx = {}}) => { | ||
return ( | ||
<Box | ||
as="main" | ||
sx={merge<BetterSystemStyleObject>( | ||
{ | ||
order: REGION_ORDER.content, | ||
|
@@ -286,6 +286,7 @@ const Pane: React.FC<PageLayoutPaneProps> = ({ | |
const computedDividerWhenNarrow = dividerWhenNarrow === 'inherit' ? divider : dividerWhenNarrow | ||
return ( | ||
<Box | ||
as="aside" | ||
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. Waiting on an answer to this question about |
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
sx={(theme: any) => | ||
merge<BetterSystemStyleObject>( | ||
|
@@ -344,6 +345,7 @@ const Footer: React.FC<PageLayoutFooterProps> = ({ | |
const {rowGap} = React.useContext(PageLayoutContext) | ||
return ( | ||
<Box | ||
as="footer" | ||
sx={merge<BetterSystemStyleObject>( | ||
{ | ||
order: REGION_ORDER.footer, | ||
|
This file contains 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
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.
ooh interesting, what does removing this do?
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.
If doesn't have role= separator, should this have aria-hidden=true instead?
Made that exact change for ActionList.Divider: #1757
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.
Good callout @siddharthkp. I believe my recommendation was to use both
role="presentation"
andaria-hidden="true"
. @colebemis, I'll update the recommendation in the a11y review issue.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.
Is this necessary to do on a
div
element?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.
Without adding
role
oraria-hidden
, it like looks divider already does not appear in the accessibility tree:What do
role
andaria-hidden
do for us in this case?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.
Ooh because it's an empty div, it would probably just get "Ignored" in the tree