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 buttons accessibility tab doc update #4240

Merged
merged 10 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
161 changes: 143 additions & 18 deletions src/pages/components/menu-buttons/accessibility.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,16 @@ import A11yStatus from 'components/A11yStatus';

<PageDescription>

No accessibility annotations are needed for overflow menus, but keep these
considerations in mind if you are modifying Carbon or creating a custom
component.
Design annotations are needed for specific instances shown below, but for the
standard menu button, combo button, and overflow menu, Carbon already
incorporates accessibility.

</PageDescription>

<InlineNotification>

**Coming soon!** The accessibility information for the menu button and combo
button is going to be updated soon.

</InlineNotification>

<AnchorLinks>

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

</AnchorLinks>
Expand All @@ -40,11 +34,83 @@ accessibility considerations, some of which are described below.

### Keyboard interaction

#### Menu button

The menu button is set in the tab order and is activated by `Space` or `Enter`.
When the menu is open, the first item takes focus. Focus is moved between menu
items with the `Up` and `Down` arrow keys. `Space` or `Enter` activates the item
with focus, which causes focus to go somewhere else and the menu to close. `Esc`
collapses the menu and puts focus back onto the menu button.

<Row>
<Column colLg={8}>

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

<Caption>
Menu button is reached by Tab. Space and Enter keys open the menu as well as
activating menu items with focus.
</Caption>

</Column>
</Row>

<Row>
<Column colLg={8}>

![illustration showing an open menu with the focus on the first item, and the arrow and Esc keys called out](images/menu-button-accessibility-2.png)

<Caption>
When opened, the first item in the menu takes focus. Arrow keys move focus and
Esc closes the menu.
</Caption>

</Column>
</Row>

#### Combo button

The combo button is set in the tab order where the first tab brings focus on the
primary button and the second tab brings focus on the icon button that contains
the menu. The respective buttons are activated by `Space` or `Enter`. When the
menu is open, the first item takes focus. Focus is moved between menu items with
the `Up` and `Down` arrow keys. `Space` or `Enter` activates the item with
focus, which causes focus to go somewhere else and the menu to close. `Esc`
collapses the menu and puts focus back onto the icon button.

<Row>
<Column colLg={8}>

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

<Caption>
Combo button items are reached by two Tab stops. Space and Enter keys open the
menu as well as activating menu items with focus.
</Caption>

</Column>
</Row>

<Row>
<Column colLg={8}>

![illustration showing an open menu with the focus on the first item, and the arrow and Esc keys called out](images/combo-button-accessibility-2.png)

<Caption>
When opened, the first item in the menu takes focus. Arrow keys move focus and
Esc closes the menu.
</Caption>

</Column>
</Row>

#### Overflow menu

Each overflow menu is in the tab order and is activated by `Space` or `Enter`.
When the menu is open, the first item takes focus. Focus is moved between menu
items with the `Up` and `Down` arrow keys. `Space` or `Enter` activates the item
with focus (which causes focus to go somewhere else and the menu to close).
`Esc` collapses the menu and puts focus onto the menu button.
with focus, which causes focus to go somewhere else and the menu to close. `Esc`
collapses the menu and puts focus onto the menu button.

<Row>
<Column colLg={8}>
Expand All @@ -65,22 +131,81 @@ with focus (which causes focus to go somewhere else and the menu to close).
![illustration showing an open menu with the focus on the first item, and the arrow and Esc keys called out](images/overflow-menu-accessibility-2.png)

<Caption>
When opened, the first item in the menu takes focus. Arrow keys move focus,
When opened, the first item in the menu takes focus. Arrow keys move focus and
Esc closes the menu.
</Caption>

</Column>
</Row>

## Design recommendations

Design annotations are needed for the following instances.

### Labeling

#### Combo button

Combo button has a prop that can be used to change the tooltip label and is only
intended to be changed to translate _'Additional actions'_ into other languages.
alina-jacob marked this conversation as resolved.
Show resolved Hide resolved
If translation is required, the translation must be annotated with a label that
is exposed on hover or focus.

<Row>
<Column colLg={8}>

![a combo button which is a part of a translated page that has an annotation 'label=अतिरिक्त कार्रवाइयां'](images/combo-button-accessibility-3.png)

<Caption>
Annotate the label for combo button so the proper tooltip appears, which
should only be used for translation purposes.
</Caption>

</Column>
</Row>

#### Overflow menu

Overflow menu’s
[custom icon variant](https://react.carbondesignsystem.com/?path=/story/components-overflowmenu--render-custom-icon)
has a prop that can be used to change the tooltip label. If the tooltip label is
changed, they must be annotated with a label that will be exposed on hover or
focus.

<Row>
<Column colLg={8}>

![a custom icon over flow menu with a share icon that has an annotation 'label=sharing options'](images/overflow-menu-accessibility-3.png)
alina-jacob marked this conversation as resolved.
Show resolved Hide resolved

<Caption>
Annotate the label for overflow menu’s custom icon variant so the proper
tooltip appears.
</Caption>

</Column>
</Row>

## Development considerations

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

- Overflow menus are buttons with `aria-haspopup` set to "true".
- The overflow menu is named with `aria-label`.
- Each menu item is an `li` in a `ul`.
- Each list item contains a button with `role="menuitem"` and `tabindex="-1"`.
See the
- Menu button, combo button, and the overflow menu are buttons with
`aria-haspopup` set to "true".
- The menu button, combo button, and the overflow menu is named with
`aria-label`.
- Each menu item across menu button, combo button, and overflow menu is an `li`
in a `ul`.
- Each list item across menu button, combo button, and overflow menu contains a
button with `role="menuitem"` and `tabindex="-1"`. See the
[ARIA authoring practices on menubutton](https://w3c.github.io/aria-practices/#menubutton)
for more considerations.
- Combo button and overflow menu has an `iconDescription` prop that can be used
to change the tooltip label. See the
[design recommendations](#design-recommendations) for more guidelines on
tooltip labels.
- For combo button, the menu is given an `id`. When the menu is open, the icon
button is given `aria-controls` with a value of the menu `id`. `aria-expanded`
is also set based on the open state.
- When the combo button menu is open, the element (`div`) wrapping the entire
Combo button is given `aria-owns` with a value of the Menu `id`.
alina-jacob marked this conversation as resolved.
Show resolved Hide resolved
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.
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.
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.
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.
6 changes: 3 additions & 3 deletions src/pages/components/menu-buttons/usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,19 @@ avoids cluttering the main interface with too many options.

#### 1. Menu button

A. Primary button <br /> C. Menu <br />
A. Primary button <br /> B. Menu <br />

#### 2. Combo button

A. Primary button <br /> B. Icon button <br /> C. Menu <br />
A. Primary button <br /> B. Menu <br /> C. Icon button <br />

</Column>

<Column colSm={2} colMd={4} colLg={4}>

#### 3. Overflow menu

A. Icon button <br /> C. Menu <br />
A. Icon button <br /> B. Menu <br />

</Column>
</Row>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/components/toggle/usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Toggle is a control that is used to quickly switch between two possible states.
Toggles are only used for these binary actions that occur immediately after the
user “flips the switch”. They are commonly used for “on/off” switches.

## Variants
### Variants

| Variant | Purpose |
| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
Expand Down
Loading