Repository navigation
[accordion][combobox][dialog][field][fieldset][menu][meter][popover][progress][select][slider][tabs][toast] Register the rendered id of labels, titles, and descriptions - #6358
Conversation
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>
commit: |
Bundle size
PerformanceNo 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. |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
- 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>
GPT Astra 6.2 reviewI 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. |
When a part gets its id from a
renderelement (render={<div id="custom" />}), the DOM element hasid="custom", but the part registered its generated id with the owner. The owner'saria-labelledbyoraria-describedbythen pointed to an id that no element has.The parts now resolve their id with the existing
resolveRenderedIdhelper (added in #5527), so the owner gets the id that the DOM element has. When the render element setsid={undefined}, the element has no id, and the owner gets no ARIA reference.Fixed parts:
Accordion.Trigger(panelaria-labelledby)Combobox.GroupLabel,Menu.GroupLabel,Select.GroupLabel(grouparia-labelledby)Combobox.Label,Select.Label(triggeraria-labelledby)Dialog.Title,Dialog.Description, and theAlertDialogandDrawerparts that reuse themPopover.Title,Popover.DescriptionField.Label,Field.Description,Field.ErrorFieldset.Legend,Meter.Label,Progress.Label,Slider.LabelTabs.Tab(panelaria-labelledby)Toast.Title,Toast.DescriptionNotes:
useRegisteredLabelIdanduseLabeltake therenderprop. The three group labels useuseRegisteredLabelIdinstead 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.id=""no longer gives the owneraria-labelledby=""oraria-describedby="".Accordion.Triggerkeeps its old behavior and uses the generated id.Field.Labelnow uses itsidprop. Before, it kept the first id that it registered and ignored a lateridchange.id={undefined}behavior from [dialog][popover][drawer] Keep generated ids when id is undefined #6343 does not change: the part keeps its generated id.aria-controlsare not in this PR.This lets Material UI remove the
Menu2GroupLabelworkaround from mui/material-ui#48823.Generated with Claude Code