Object and array containers are named groups carrying the field's id
Detect
- In your CSS or tests, a selector that finds an object's or array's title, description or contents by where they sit in the DOM, such as a direct-child selector.
- A test that calls
getByRole('group')without a name, or finds a container by the field'sid. - Snapshot tests of forms with objects or arrays in these themes.
Change
An object's or an array's title, description and contents are now a group, named by the title and described by the field's errors, description and help, so a screen reader reads them together (#5723):
- In
@rjsf/chakra-ui,@rjsf/fluentui-rc,@rjsf/muiand@rjsf/react-bootstrap,ObjectFieldTemplaterendered them with no element around them, and in@rjsf/fluentui-rcso didArrayFieldTemplate. They now render inside adivwithrole="group"carrying the field'sid. @rjsf/daisyui'sArrayFieldTemplateandObjectFieldTemplate,@rjsf/mantine'sObjectFieldTemplate, and theArrayFieldTemplateof@rjsf/chakra-ui,@rjsf/muiand@rjsf/react-bootstrapgive the element they already renderedrole="group", and the field'sidwhere it didn't carry it.- A
<fieldset>, which every other container renders, is a group already, and only gains the name and description.
Point a child selector at the new div, as in [role="group"] > .... A test calling getByRole('group') can now find the root object's group as well, so give it the group's name or search within the field:
-screen.getByRole('group');
+screen.getByRole('group', { name: 'Pets' });
Verify
- Each object and array container is found by
getByRole('group', { name })with its title. - Snapshots gain the group element or its
roleandid; update them.
Also read: