Skip to content

Improve accessibility of toggle and checkbox menu items#377

Merged
robintown merged 5 commits intomainfrom
toggle-accessibility
Jan 9, 2026
Merged

Improve accessibility of toggle and checkbox menu items#377
robintown merged 5 commits intomainfrom
toggle-accessibility

Conversation

@robintown
Copy link
Member

@robintown robintown commented Aug 14, 2025

MenuItems can be used either inside a Menu component (which creates a roving tab index) or simply with an element of role menu. In the latter case, focus would previously land on the cosmetic <input> element, which is a bad idea as it's hidden from accessibility technologies. By turning the parent <div role="menuitemcheckbox"> into a <button> instead, we can ensure that focus always lands on the parent element. This is possible because ToggleMenuItem and CheckboxMenuItem are controlled components these days.

MenuItems can be used either inside a Menu component (which creates a roving tab index) or simply with an element of role menu. In the latter case, focus would previously land on the cosmetic <input> element, which is a bad idea as it's hidden from accessibility technologies. By turning the parent <div role="menuitemcheckbox"> into a <button> instead, we can ensure that focus always lands on the parent element. This is possible because ToggleMenuItem and CheckboxMenuItem are controlled components these days.
@robintown robintown requested a review from a team as a code owner August 14, 2025 12:02
@robintown robintown requested review from t3chguy and removed request for a team August 14, 2025 12:02
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Aug 14, 2025

Deploying compound-web with  Cloudflare Pages  Cloudflare Pages

Latest commit: 55832e1
Status: ✅  Deploy successful!
Preview URL: https://05f4c93a.compound-web.pages.dev
Branch Preview URL: https://toggle-accessibility.compound-web.pages.dev

View logs

@robintown
Copy link
Member Author

@t3chguy Are you still interested in giving this change a review? I recall you brought it up when looking at menus in Element Web, but it would also benefit Element Call.

@t3chguy
Copy link
Member

t3chguy commented Dec 3, 2025

@robintown can you make CI happy?

@robintown
Copy link
Member Author

@t3chguy Have finally done so.

Copy link
Member

@t3chguy t3chguy left a comment

Choose a reason for hiding this comment

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

LGTM, one thing I noticed (not affected by this PR) is disabled items are not reachable by keyboard so disabled items are almost invisible to non-sighted users, if you're still in the area of improving accessibility that'd be a good one to resolve

@robintown robintown merged commit 4959248 into main Jan 9, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants