shadcn's SelectWidget names its combobox and fills an empty placeholder
Detect
- Snapshot or visual tests of
@rjsf/shadcnforms with aSelectWidget. - In your tests, a query for the single select's trigger by the
buttonrole. - A
ui:placeholderon a multiple select, or a single select without one.
Change
The multiple SelectWidget rendered its cmdk search combobox with no accessible name, and its search input always showed a hard-coded, untranslated "Select ..." that ignored ui:placeholder. The single SelectWidget rendered a blank trigger where no ui:placeholder was given (#5458).
- The multiple select's combobox is named from the field's resolved label: the schema
titleor aui:titleoverride, falling back toui:placeholderand then to the newTranslatableString.SelectPlaceholder("Select ...") for an untitled field. - The same fallback replaces the search input's hard-coded placeholder, and the field's description and
aria-requiredreach the focusable combobox input. - The single select fills its empty trigger from the same fallback, so without
ui:placeholderit shows the translated placeholder. - The single select's trigger has the
comboboxrole, so it holds the option it displays as its value and isaria-invalidandaria-requiredas its field is. With no label drawn for it, it is named by the field's label or, for an untitled field, by itsui:placeholder, elseTranslatableString.SelectPlaceholder.
Query the trigger by the combobox role:
-screen.getByRole('button', { name: 'Color' });
+screen.getByRole('combobox', { name: 'Color' });
A translateString table of your own gains the SelectPlaceholder key; see A translateString that maps every key needs the new TranslatableString keys.
Verify
- Visual snapshots change where a single select without
ui:placeholdergoes from blank to "Select ...", and where a multiple select with one shows it in place of "Select ...". - Every select is found by
getByRole('combobox', { name }).
Also read: