react-jsonschema-form
react-jsonschema-form copied to clipboard
feature request: button-add for non-required objects
Prerequisites
- [x] I have read the documentation;
- [x] In the case of a bug report, I understand that providing a SSCCE example is tremendously useful to the maintainers.
Description
A schema may define a set of objects as properties. A subset of those properties may be required by the schema. Currently react-jsonschema-form expands all objects (required or not). It would save space to collapse objects not required and provide a button to add the object if desired. Additionally, if the unrequired object has required fields when present, the validator will require the required fields in the unrequired object be filled in (even though they are only required when the object exists).
Steps to Reproduce
Expected behavior
Ideally, string 1 and object 1 would be displayed and object 2 would be collapsed so everything below it was not shown. String 3 would not be required because no object 2 had been created.
Actual behavior
All properties and subproperties are shown. String 3 is required even though object 2 is empty.
Version
0.48.2
Hi, thanks for your comment. I agree that this would be useful. We've had a longstanding wishlist item for collapsing fields or hiding them (#322/#324, #578, your own #598). I would be interested in reviewing a PR that added this feature if it could be done in a clean way.