react-jsonschema-form
react-jsonschema-form copied to clipboard
ObjectFieldTemplate Never gets the uiSchema passed into it
Prerequisites
- [X] I have searched the existing issues
- [X] I understand that providing a SSCCE example is tremendously useful to the maintainers.
- [X] I have read the documentation
- [X] Ideally, I'm providing a sample JSFiddle or a shared playground link demonstrating the issue.
What theme are you using?
mui
Version
5.x
Current Behavior
Inside the MUI method : ObjectFieldTemplate(props).
The uiSchema is never passed in through the props, I am trying to extend the functionality a little you see and wanted to do through using ui:options.
However the object never seems to get passed in
Expected Behavior
I would expect that uiSchema would exist on this object since it's referenced and there are calls using it inside the method.
I've attached some hacky code to show you where this is missing.
Steps To Reproduce
/** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
* title and description if available. If the object is expandable, then an `AddButton` is also rendered after all
* the properties.
*
* @param props - The `ObjectFieldTemplateProps` for this component
*/
function ObjectFieldTemplate(props) {
var description = props.description,
title = props.title,
properties = props.properties,
required = props.required,
disabled = props.disabled,
readonly = props.readonly,
uiSchema = props.uiSchema,
idSchema = props.idSchema,
schema = props.schema,
formData = props.formData,
onAddClick = props.onAddClick,
registry = props.registry;
var uiOptions = utils.getUiOptions(uiSchema);
var TitleFieldTemplate = utils.getTemplate("TitleFieldTemplate", registry, uiOptions);
var DescriptionFieldTemplate = utils.getTemplate("DescriptionFieldTemplate", registry, uiOptions);
// Button templates are not overridden in the uiSchema
var AddButton = registry.templates.ButtonTemplates.AddButton;
var fullWidth = uiOptions.columnWidth ? false : true;
var columnWidth = uiOptions.columnWidth || 6;
console.log("object field PROPS", props);
console.log("object field UIOPTIONS", uiOptions); // always empty
console.log("object field FW", fullWidth);
console.log("object field CW", columnWidth);
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, (uiOptions.title || title) && /*#__PURE__*/React__default["default"].createElement(TitleFieldTemplate, {
id: utils.titleId(idSchema),
title: title,
required: required,
schema: schema,
uiSchema: uiSchema,
registry: registry
}), (uiOptions.description || description) && /*#__PURE__*/React__default["default"].createElement(DescriptionFieldTemplate, {
id: utils.descriptionId(idSchema),
description: uiOptions.description || description,
schema: schema,
uiSchema: uiSchema,
registry: registry
}), /*#__PURE__*/React__default["default"].createElement(Grid__default["default"], {
container: true,
spacing: 2,
style: {
marginTop: "10px"
}
}, properties.map(function (element, index) {
return (
// Remove the <Grid> if the inner element is hidden as the <Grid>
// itself would otherwise still take up space.
element.hidden ? element.content : /*#__PURE__*/React__default["default"].createElement(Grid__default["default"], {
item: true,
xs: 12,
key: index,
style: {
marginBottom: "10px"
}
}, element.content)
);
}), utils.canExpand(schema, uiSchema, formData) && /*#__PURE__*/React__default["default"].createElement(Grid__default["default"], {
container: true,
justifyContent: "flex-end"
}, /*#__PURE__*/React__default["default"].createElement(Grid__default["default"], {
item: true
}, /*#__PURE__*/React__default["default"].createElement(AddButton, {
className: "object-property-expand",
onClick: onAddClick(schema),
disabled: disabled || readonly,
uiSchema: uiSchema,
registry: registry
})))));
}
Environment
Node
Anything else?
No response
I believe this is line 238 in this file where it's set to {}
https://github.com/rjsf-team/react-jsonschema-form/blob/5555123b72c040f47eb2d9299de9bd3603888248/packages/core/src/components/fields/ObjectField.tsx
@gurnro If you can't reproduce this in the playground, could you link to a Codepen or JSFiddle example so someone can get to the bottom of this? Or you are welcome to create a pull request yourself. Thanks!
Hi Nick, Ive been trying to get to the bottom of it in the code so I can do a PR!
@gurnro Awesome, thanks for being willing to contribute
This issue has been automatically marked as possibly close because it has not had recent activity. It will be closed if no further activity occurs. Please leave a comment if this is still an issue for you. Thank you.
This issue was closed because of lack of recent activity. Reopen if you still need assistance.
@gurnro Are you able to help fix this?
This issue was closed because of lack of recent activity. Reopen if you still need assistance.