Skip to content
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

Improve usage and documentation of the landmark region labels. #7940

Merged
merged 1 commit into from
Jul 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions components/higher-order/navigate-regions/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# navigateRegions

`navigateRegions` is a React [higher-order component](https://facebook.github.io/react/docs/higher-order-components.html) adding keyboard navigation to switch between the different DOM elements marked as "regions" (role="region"). These regions should be focusable (By adding a tabIndex attribute for example)
`navigateRegions` is a React [higher-order component](https://facebook.github.io/react/docs/higher-order-components.html) adding keyboard navigation to switch between the different DOM elements marked as "regions" (role="region"). These regions should be focusable (By adding a tabIndex attribute for example). For better accessibility, these elements must be properly labelled to briefly describe the purpose of the content in the region. For more details, see "ARIA landmarks" in the [WAI-ARIA specification](https://www.w3.org/TR/wai-aria/).

## Example:

```jsx
function MyLayout() {
return (
<div>
<div role="region" tabIndex="-1">Header</div>
<div role="region" tabIndex="-1">Content</div>
<div role="region" tabIndex="-1">Sidebar</div>
<div role="region" tabIndex="-1" aria-label="Header">Header</div>
<div role="region" tabIndex="-1" aria-label="Content">Content</div>
<div role="region" tabIndex="-1" aria-label="Sidebar">Sidebar</div>
</div>
);
}

export default navigateRegions( MyLayout );
```
```
3 changes: 2 additions & 1 deletion edit-post/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ function Header( {
return (
<div
role="region"
aria-label={ __( 'Editor toolbar' ) }
/* translators: accessibility text for the top bar landmark region. */
aria-label={ __( 'Editor top bar' ) }
className="edit-post-header"
tabIndex="-1"
>
Expand Down
11 changes: 9 additions & 2 deletions edit-post/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ function Layout( {

const publishLandmarkProps = {
role: 'region',
'aria-label': __( 'Publish' ),
/* translators: accessibility text for the publish landmark region. */
'aria-label': __( 'Editor publish' ),
tabIndex: -1,
};
return (
Expand All @@ -76,7 +77,13 @@ function Layout( {
} } />
<AutosaveMonitor />
<Header />
<div className="edit-post-layout__content" role="region" aria-label={ __( 'Editor content' ) } tabIndex="-1">
<div
className="edit-post-layout__content"
role="region"
/* translators: accessibility text for the content landmark region. */
aria-label={ __( 'Editor content' ) }
tabIndex="-1"
>
<EditorNotices />
<PreserveScrollInReorder />
<EditorModeKeyboardShortcuts />
Expand Down