Skip to content

fix(menu): wrap web menu items in a named menu role - #5362

Open
Priyanshu0007 wants to merge 1 commit into
callstack:mainfrom
Priyanshu0007:fix/menu-web-role
Open

Priyanshu0007 wants to merge 1 commit into
callstack:mainfrom
Priyanshu0007:fix/menu-web-role

Conversation

@Priyanshu0007

Copy link
Copy Markdown
Contributor

Motivation

On web, Menu.Items are menuitems with no menu parent, so screen readers get no menu name or item count. The menu also set aria-modal without a dialog role. axe-core flags both as critical.

Related issue

Fixes #5349

Screenshots / Videos

Web, before / after:

menu-role-web-before.mp4
menu-role-web-after.mp4

iOS, unchanged:

menu-role-ios-before.mp4
menu-role-ios-after.mp4

Android, unchanged:

menu-role-android-before.mp4
menu-role-android-after.mp4

Test plan

  1. On web, open Menu > "Menu with icons".
  2. DevTools > Accessibility shows the items in menu "Menu with icons".
  3. axe-core reports no violations.

On web, Menu items are menuitems, but nothing around them had role=menu, so axe flagged aria-required-parent and screen readers got no menu name or item count. The content also carried aria-modal without a dialog role.

The menu content now has role=menu on web, named by its anchor through aria-labelledby, or by a new aria-label prop for position anchors. aria-modal stays on iOS only.

Fixes callstack#5349

This branch has not been deployed

No deployments
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.

Menu on web: the items are menuitems with no menu around them, and aria-modal sits on an element with no role

1 participant