rjsf-team/react-jsonschema-form

Option to hide dropdown for single-option oneOf / anyOf / allOf

Open

#3425 aperta il 2 feb 2023

Vedi su GitHub
 (8 commenti) (0 reazioni) (0 assegnatari)TypeScript (2136 fork)batch import
featurehelp wanted

Metriche repository

Star
 (13.175 star)
Metriche merge PR
 (Merge medio 3g 17h) (32 PR mergiate in 30 g)

Descrizione

Prerequisites

What theme are you using?

core

Is your feature request related to a problem? Please describe.

We have a project where users build schemas composed of other schemas. We extend and limit JSON schema using custom meta-schemas to standardize certain things.

The relevant consequence of this is that it is possible to end up with oneOf and allOf fields that contain one item, which means an unnecessary dropdown containing one item.

For our purposes, it would be great to have an option to hide the dropdown if it only contains one option.

Describe the solution you'd like

A uiSchema option which, if true, would hide the select widget in MultiSchemaField if it contained only one option.

Describe alternatives you've considered

I appreciate that this is a non-standard use case that depends on both: (a) allowing users to create schemas which are unknown ahead of time (b) using fields such as oneOf even if the schema could be represented in normal JSON schema without them

I have considered patching or forking the library, or using a custom MultiSchemaField which implemented the behavior above. I suspect the last is likely the best option absent in-built support but welcome advice. All would be messier and require ongoing investment to keep up to date, so I thought I would see if there was any appetite for this feature first.

Guida contributor