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

Menu accessibility tab doc update #4250

Merged
merged 21 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
76 changes: 73 additions & 3 deletions src/pages/components/menu/accessibility.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,80 @@ tabs: ['Usage', 'Style', 'Code', 'Accessibility']

import A11yStatus from 'components/A11yStatus';

<InlineNotification>
<PageDescription>

**Coming soon!** This page is a work in progress.
No accessibility annotations are needed for menus, but keep these considerations
in mind if you are modifying Carbon or creating a custom component.

</InlineNotification>
</PageDescription>

<AnchorLinks>

<AnchorLink>What Carbon provides</AnchorLink>
<AnchorLink>Development considerations</AnchorLink>

</AnchorLinks>

## What Carbon provides

Carbon bakes keyboard operation into its components, improving the experience of
blind users and others who operate via keyboard. Carbon also incorporates other
alina-jacob marked this conversation as resolved.
Show resolved Hide resolved
accessibility considerations, some of which are described below.

### Keyboard interaction

The menu is reached by tab. When the menu is open, the first item takes focus.
alina-jacob marked this conversation as resolved.
Show resolved Hide resolved
The menu items are navigated using the `Up` and `Down` arrow keys.
alina-jacob marked this conversation as resolved.
Show resolved Hide resolved

<Row>

<Column colLg={8}>

![example of menu keyboard interaction](images/accessibility-menu-1.png)

<Caption>
Menu is reached by tab and when opened, the first menu item takes focus. Arrow
alina-jacob marked this conversation as resolved.
Show resolved Hide resolved
keys move focus.
</Caption>

</Column>
</Row>

Pressing `Space` or `Enter` on a focused menu item activates it and collapses
the menu or activates the sub-menu. An activated menu item can have different
results depending on its functionality. If the item is a link, it launches the
selection. If the item is selectable, it selects or deselects the item. If
multiple items are selectable in a menu, that is one of many, selection switches
to that item, and it shows up as selected when the menu is opened again.

<Row>
<Column colLg={8}>

![example of menu keyboard interaction](images/accessibility-menu-2.png)
alina-jacob marked this conversation as resolved.
Show resolved Hide resolved

<Caption>
Space and Enter keys activates/selects/deselects the menu item with focus.
alina-jacob marked this conversation as resolved.
Show resolved Hide resolved
</Caption>

</Column>
</Row>

## Development considerations
alina-jacob marked this conversation as resolved.
Show resolved Hide resolved

Keep these considerations in mind if you are modifying Carbon or creating a
custom component.

- Each menu, including nested menus, are `ul` elements with `role="menu"`
- Menu items are `li` elements with `role="menuitem"`
- If a Menu item contains a sub-menu, it is given `aria-haspopup="true"` and
`aria-expanded` of true or false depending on if the sub-menu is open/visible.
- Selectable menu items are given `role="menuitemcheckbox"`
- Menu item groups are 'li' elements with `role="group"`
alina-jacob marked this conversation as resolved.
Show resolved Hide resolved
- Menu item radio groups get `role="menuitemradio"`
- Menu items with really long label can get truncated depending on screen sizes.
alina-jacob marked this conversation as resolved.
Show resolved Hide resolved
This label will be exposed by a browser rendered tooltip on hover or focus.
- Menu implements the
[menu design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/menubar/)
defined in the ARIA Authoring Practices Guide (APG).

<A11yStatus layout="table" components="Menu" />
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/pages/components/menu/images/usage-menu-RTL.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/pages/components/menu/usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,8 @@ including the direction of the caret and keyboard shortcuts.
#### Overflow

Consider using short and precise labels for menu items. However, when deciding
to truncate long menu items, use a tooltip on hover to reveal the full text.
to truncate long menu items, a browser rendered title tooltip will reveal the
full text on hover.

<Row>
<Column colLg={8}>
Expand Down
Loading