rjsf-team/react-jsonschema-form

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

開放

#3,425 建立於 2023年2月2日

 (8 則留言) (0 個反應) (0 位負責人)TypeScript (2,136 個分叉)batch import
featurehelp wanted

倉庫指標

星標
 (13,175 顆星)
PR 合併指標
 (平均合併 3天 17小時) (30 天內合併 32 個 PR)

描述

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.

貢獻者指南