Skip to content

[menubar] Fix menubar a11y tree to satisfy aria-required-children - #5058

Merged
michaldudak merged 3 commits into
mui:masterfrom
michaldudak:codex/fix-portal-aria-owns-owner
Aug 13, 2026
Merged

michaldudak merged 3 commits into
mui:masterfrom
michaldudak:codex/fix-portal-aria-owns-owner

Conversation

@michaldudak

Copy link
Copy Markdown
Member

This is an alternative to #4027.
It renders the span with aria-owns with role=group. Groups are allowed within menus and an empty group does not mess up the accessibility tree.

Lighthouse does not complain anymore.

Fixes #4004

@pkg-pr-new

pkg-pr-new Bot commented Jun 17, 2026 •

Copy link
Copy Markdown
  • base-ui-tanstack-start

  • vite-css-base-ui-example

    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/react@5058
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@5058
    

commit: 7cb2d95

@code-infra-dashboard

code-infra-dashboard Bot commented Jun 17, 2026 •

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+122B(+0.03%) 🔺+55B(+0.04%)

Details of bundle changes

Performance

Total duration: 1,313.57 ms -21.20 ms(-1.6%) | Renders: 76 (+0) | Paint: 2,062.06 ms -20.47 ms(-1.0%)

Test Duration Renders
Tooltip mount (300 contained roots) 71.40 ms 🔺+21.62 ms(+43.4%) 1 (+0)
Checkbox mount (500 instances) 86.59 ms 🔺+17.38 ms(+25.1%) 1 (+0)
Popover mount (300 instances) 88.21 ms 🔺+15.62 ms(+21.5%) 1 (+0)
Mixed surface mount (app-like density) 65.69 ms ▼-28.04 ms(-29.9%) 5 (+0)
Combobox open — 500 items 44.68 ms ▼-19.07 ms(-29.9%) 4 (+0)

10 tests within noise — details

Metric alarms

Test Metric Change
Tooltip mount (300 contained roots) bench:paint 🔺 +29.95 ms
Checkbox mount (500 instances) bench:paint 🔺 +22.89 ms

Check out the code infra dashboard for more information about this PR.

@netlify

netlify Bot commented Jun 17, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 7cb2d95
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a7d8c5435711c0008008c82
😎 Deploy Preview https://deploy-preview-5058--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c1297ed190

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<MenuPortalContext.Provider value={keepMounted}>
<FloatingPortal ref={forwardedRef} {...portalProps} />
{/* The hidden `aria-owns` owner must be an allowed child of `menu` and `menubar`. */}
<FloatingPortal ref={forwardedRef} {...portalProps} portalOwnerRole="group" />

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Gate the hidden owner role to menu parents

When Menu.Portal belongs to a plain root Menu.Root (parent.type is undefined), the hidden aria-owns span is rendered next to the trigger rather than as a child of a menu/menubar, so the aria-required-children workaround is not needed there. Passing portalOwnerRole="group" unconditionally makes every open root menu expose an extra accessible group (the updated group-label tests had to scope getByRole('group') to avoid this new owner), which changes regular menu semantics for assistive tech. Please only pass the group role for the contexts that need it, such as submenu and menubar parents.

Useful? React with 👍 / 👎.

@atomiks atomiks left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems like Menubars don't work with VoiceOver virtual cursor to begin with (tested master with Safari and Chrome on Mac — it just moves to the browser minimise buttons). This PR doesn't change anything from what I tested. And iOS VoiceOver is also still fine.

@michaldudak
michaldudak requested a review from jjenzz as a code owner June 17, 2026 07:40

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c4eb9e7453

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jun 29, 2026
@michaldudak
michaldudak force-pushed the codex/fix-portal-aria-owns-owner branch from c4eb9e7 to 534fe4a Compare August 13, 2026 08:23
@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Aug 13, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d9e69d1b49

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@michaldudak
michaldudak merged commit 1b94c96 into mui:master Aug 13, 2026
6 checks passed
@michaldudak
michaldudak deleted the codex/fix-portal-aria-owns-owner branch August 13, 2026 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accessibility a11y component: menubar Changes related to the menubar component.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[menubar] when dropped down, has children which are not allowed: span[aria-owns]

2 participants