Skip to content

[accordion][combobox][dialog][field][fieldset][menu][meter][popover][progress][select][slider][tabs][toast] Register the rendered id of labels, titles, and descriptions - #6358

Open
LukasTy wants to merge 3 commits into
mui:masterfrom
LukasTy:rendered-id-labels

Conversation

@LukasTy

@LukasTy LukasTy commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

When a part gets its id from a render element (render={<div id="custom" />}), the DOM element has id="custom", but the part registered its generated id with the owner. The owner's aria-labelledby or aria-describedby then pointed to an id that no element has.

The parts now resolve their id with the existing resolveRenderedId helper (added in #5527), so the owner gets the id that the DOM element has. When the render element sets id={undefined}, the element has no id, and the owner gets no ARIA reference.

Fixed parts:

  • Accordion.Trigger (panel aria-labelledby)
  • Combobox.GroupLabel, Menu.GroupLabel, Select.GroupLabel (group aria-labelledby)
  • Combobox.Label, Select.Label (trigger aria-labelledby)
  • Dialog.Title, Dialog.Description, and the AlertDialog and Drawer parts that reuse them
  • Popover.Title, Popover.Description
  • Field.Label, Field.Description, Field.Error
  • Fieldset.Legend, Meter.Label, Progress.Label, Slider.Label
  • Tabs.Tab (panel aria-labelledby)
  • Toast.Title, Toast.Description

Notes:

  • useRegisteredLabelId and useLabel take the render prop. The three group labels use useRegisteredLabelId instead of a copy of its effect. The Dialog and Popover titles and descriptions also use it, so a part that unmounts or loses its id releases only its own id.
  • An explicit id="" no longer gives the owner aria-labelledby="" or aria-describedby="". Accordion.Trigger keeps its old behavior and uses the generated id.
  • Field.Label now uses its id prop. Before, it kept the first id that it registered and ignored a later id change.
  • The id={undefined} behavior from [dialog][popover][drawer] Keep generated ids when id is undefined #6343 does not change: the part keeps its generated id.
  • Popup ids that triggers reference with aria-controls are not in this PR.

This lets Material UI remove the Menu2GroupLabel workaround from mui/material-ui#48823.

Generated with Claude Code

A part that gets its id from a `render` element now registers that id
with its owner, so `aria-labelledby` and `aria-describedby` point to an
element that exists. When the render element removes the id, the owner
gets no reference.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@LukasTy LukasTy added component: select Changes related to the select component. component: menu Changes related to the menu component. component: alert dialog Changes related to the alert dialog component. component: tabs Changes related to the tabs component. component: slider Changes related to the slider component. type: bug It doesn't behave as expected. component: drawer Changes related to the drawer component. component: accordion Changes related to the accordion component. component: dialog Changes related to the dialog component. accessibility a11y component: popover Changes related to the popover component. component: toast Changes related to the toast component. component: progress Changes related to the progress component. component: field Changes related to the field component. component: meter Changes related to the meter component. component: combobox Changes related to the combobox component. component: fieldset labels Nov 26, 2026
@pkg-pr-new

pkg-pr-new Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

commit: 14df40e

@code-infra-dashboard

code-infra-dashboard Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Bundle size

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

Details of bundle changes

Performance

No regressions in 36 benchmarks · precise to ±8.9% (±13.4% at worst) · ran 3m 27s · details


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

@netlify

netlify Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 14df40e
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6b098c98c488fd8bb6e42a30
😎 Deploy Preview https://deploy-preview-6358--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.

LukasTy and others added 2 commits November 27, 2026 15:39
- Field.Error resolves the render id only while mounted, so a pending lazy render element does not suspend the field.
- An id-less label or toast part releases only its own id and does not clear the id of another part.
- Field.Label uses its id prop, not the id that it registered before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Dialog.Title, Dialog.Description, Popover.Title, and Popover.Description now register their id through useRegisteredLabelId. An older part that loses its id or unmounts no longer clears the id of a newer part.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@LukasTy

LukasTy commented Nov 27, 2026

Copy link
Copy Markdown
Member Author

GPT Astra 6.2 review

I would approve this head. No remaining code findings in the documented component configurations.

All eight new Dialog and Popover regression tests failed on the preceding commit a1950bd and passed on 14df40e. They cover retaining the newer accessible name or description when an older part removes its ID or unmounts. The earlier Field.Error, Field.Label, Select.GroupLabel and Toast.Title reproductions also pass. The two-trigger Accordion case still reproduces outside the documented one-trigger-per-item configuration.

@LukasTy
LukasTy marked this pull request as ready for review November 27, 2026 14:25

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

accessibility a11y component: accordion Changes related to the accordion component. component: alert dialog Changes related to the alert dialog component. component: combobox Changes related to the combobox component. component: dialog Changes related to the dialog component. component: drawer Changes related to the drawer component. component: field Changes related to the field component. component: fieldset component: menu Changes related to the menu component. component: meter Changes related to the meter component. component: popover Changes related to the popover component. component: progress Changes related to the progress component. component: select Changes related to the select component. component: slider Changes related to the slider component. component: tabs Changes related to the tabs component. component: toast Changes related to the toast component. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant