A discriminated layout grid cell renders inside a full field wrapper
Detect
- In your
uiSchema: aLayoutGridFieldthat lays out a discriminatedoneOf/anyOf, whose option selector renders in a cell of its own. - In your CSS: rules matching
.rjsf-field,.rjsf-field-<type>or.rjsf-field-errorthat now also match that cell's wrapper. - In that cell's
uiSchemaor schema:ui:classNames,ui:style,ui:widget: 'hidden',ui:description,ui:help,ui:disabled,ui:autofocus,deprecated, a$refwith aui:definitionsentry, or no title.
Change
LayoutMultiSchemaField rendered that cell outside any SchemaField and built its FieldTemplate's props itself, so each prop it left out was missing for that one field (#5327). The grid now renders the cell through SchemaField, as it renders every other cell, and LayoutMultiSchemaField renders only the selector widget (#5419). For a form that renders one of these cells:
- A rule matching
.rjsf-field,.rjsf-field-<type>or.rjsf-field-errornow matches the cell's wrapper. A rule meant to exclude these cells has to say so. ui:classNamesandui:styleon the cell are applied by theFieldTemplatewrapper.- The template is handed
hidden,formData,description,rawDescription,helpandrawHelp. Aui:widget: 'hidden'now hides the cell, where the widget used to render inside the full wrapper, and aui:description,schema.descriptionorui:helpon it now renders. ui:disabledand adeprecatedschema are resolved as for any other field.ui:disableddisables the cell and its selector, and re-enables them when it isfalseon a form or grid that disables everything. A deprecated cell is hidden byui:deprecatedHandling: 'hide', disabled by'disable', and under the'label'default gets the deprecation marker on its label, which itsFieldTemplateand selector both receive.- A cell with no title is labelled by its property name, as every other cell is, where it was unlabelled; see An untitled nested layout grid cell is labelled by its property name. The selector is still named by its text.
- A
$refcell takes itsui:definitionsentry, so a definition shared with a field elsewhere now gives the cell itsui:widget,ui:titleand the rest. ui:autofocuson the cell focuses its selector, where nothing took focus.- A selector property with no
type, and none itsconstorenumimplies, takes the type of the first option that isn't a boolean schema, declared or inferred, where it took the selected option's. Its widget no longer depends on the data, and a selector with no option selected renders, where it threw. With no option to take a type from, as when every option is a boolean schema, it is typed as an object, and takes its default widget orselect,radioorhidden. - A cell whose
oneOf/anyOfis empty renders the field its schema would without the keyword, where it threw.
Give the cell a ui:title, or set ui:label: false to hide the label:
const uiSchema = {
- shape: {},
+ shape: { 'ui:title': 'Shape' },
};
The type class is rjsf-field-undefined for the usual discriminated schema, { discriminator, oneOf: [{ $ref }, ...] }, which declares no top-level type. A later release may drop that class or derive it from the selected option, so key rules off .rjsf-field, which every field carries.
computeEnumOptions() and getSelectedOption() can no longer be imported; see Imports from a package's lib folder no longer resolve.
Verify
- The cell's wrapper carries
rjsf-fieldand yourui:classNames, and the description, help, label, disabled state and focus you set show on it. - Your field-wide CSS rules style the cell as you intend.
Also read:
- A custom selector widget or template in a discriminated grid cell loses ui:classNames and display-label cues
- A custom LayoutMultiSchemaField renders only the selector and gets no options prop
- An untitled nested layout grid cell is labelled by its property name
- Imports from a package's lib folder no longer resolve