A SelectWidget or RadioWidget of your own applies the names rjsf hands it
Detect
- In your code, a
SelectWidgetorRadioWidgetpassed inwidgetsor a theme, replacing the theme's own. - A custom
ui:fieldthat renders the registry'sSelectWidgetand hands it itspresentation. - On the rendered page,
AltDateWidgetparts or untitled selects with no accessible name.
Change
DateElement hands each date part's name and description to the registry's SelectWidget as its aria-label and aria-describedby. Every theme's SelectWidget gives them to the control a screen reader focuses through the new widgetAriaProps(), which describes it by the caller's ids and, while it shows one, by the id of the selected option's description, listed where it is drawn among the field's description and help.
A replacement SelectWidget must do the same, or the date parts it renders are left unnamed and undescribed. No other widget is required to honor the two props:
import { widgetAriaProps, WidgetProps } from '@rjsf/utils';
function MySelectWidget(props: WidgetProps) {
return <select id={props.id} {...widgetAriaProps(props)}>{/* ... */}</select>;
}
widgetAriaProps() also names a select no label names by its ui:placeholder, else TranslatableString.SelectPlaceholder ("Select ..."). A replacement SelectWidget that draws its field's label itself, as widgetDrawsLabelText(props) says, takes no such name, since that label names the select. One whose plan has it draw its label must draw it, or the select is left with no name.
So must a custom ui:field that hands its presentation on to the registry's SelectWidget, since that plan has the field draw the label: it draws one or passes the widget an aria-label.
getGroupAttributes() names a radiogroup no label names the same way, by its ui:placeholder, else TranslatableString.RadioGroupName ("Choose an option"), when the widget passes it its label, placeholder and registry, as every theme's RadioWidget does. A replacement RadioWidget should pass them too (#5586).
A replacement SelectWidget also receives undefined for an unset date part; see An unset AltDateWidget date part is undefined in every theme.
Verify
Run controlNameTests(Form) from @rjsf/snapshot-tests against your theme's Form. It checks that date parts, unlabelled selects and radio groups are named.
Also read: