rjsf-team/react-jsonschema-form

Array bug with additionalItems and empty items

Geschlossen

#3.791 geöffnet am 27.07.2023

 (5 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)TypeScript (2.136 Forks)batch import
additionalPropertiesarraysbughelp wanted

Repository-Metriken

Stars
 (13.175 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 3T 17h) (32 gemergte PRs in 30 T)

Beschreibung

Prerequisites

What theme are you using?

core

Version

5.x

Current Behavior

The additionalItems keyword allows one to provide a fixed-length array but allow the user the ability to add on to the end of it. However, this does not work if the fixed-length array is empty. Instead, the form appears to render but the "+" button to add additional items to the array does not work.

Broken Example with Empty Items

The behavior of the additionalItems array should look almost identical (apart from a little extra spacing) to the case where the fixed-length array has one null element with no other information to render: Working Example with One Item

Of course, there is a workaround, which is to move the array item definition in additionalItems into items, since we are no longer really making use of that fixed-length array when it is empty. It would still be preferable if this worked as expected, especially when working with fixed-length arrays of varying lengths -- having to specially handle the case of an array of length 0 adds unnecessary additional complexity.

Contributor Guide