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

[docs] Fix a11y in Menu demos #30378

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion docs/src/pages/components/menus/BasicMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function BasicMenu() {
<div>
<Button
id="basic-button"
aria-controls="basic-menu"
aria-controls={open ? 'basic-menu' : undefined}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks correct based on https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-controls

A combobox element has aria-controls set to a value that refers to the element that serves as the popup. The aria-controls only needs to be set when the popup is visible, but it is valid and easier to program to reference an element that is not visible.

Copy link
Member

@oliviertassinari oliviertassinari Dec 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that in our case, it's even more than non-visible => non-existent.

On a different note, the thread in w3c/aria#995 (comment) suggests that the attribute is close to poop.

aria-haspopup="true"
aria-expanded={open ? 'true' : undefined}
onClick={handleClick}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/menus/BasicMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function BasicMenu() {
<div>
<Button
id="basic-button"
aria-controls="basic-menu"
aria-controls={open ? 'basic-menu' : undefined}
oliviertassinari marked this conversation as resolved.
Show resolved Hide resolved
aria-haspopup="true"
aria-expanded={open ? 'true' : undefined}
onClick={handleClick}
Expand Down