react-jsonschema-form icon indicating copy to clipboard operation
react-jsonschema-form copied to clipboard

Add `minRemovable` options

Open mfulton26 opened this issue 8 years ago • 3 comments
trafficstars

RJSF supports addable and removable options but does not currently support hiding the remove buttons when minItems is met. I propose the following option (or similarly named one) be added:

minRemovable option

A remove button is shown by default even when the number of items is less than or equal to minItems. You can turn this off with the minRemovable option in uiSchema:

const uiSchema = {
  "ui:options":  {
    minRemovable: false
  }
};

mfulton26 avatar Jul 15 '17 15:07 mfulton26

I've since learned that the add button is not shown once maxItems is worth so I've updated this issue to only add a minRemovable option.

mfulton26 avatar Nov 24 '17 03:11 mfulton26

Hmm. I didn't realize we don't show an add button once we reach maxItems. (I even wrote about it in the README.) Personally, I would have said we should show buttons in all cases. I agree that some users want to prevent users from "coloring outside of the lines", as it were, but I feel like such a granular option as minRemovable is too granular -- in general, I would expect a developer to either want none of the safety guards, or all of them. So I would prefer to see a larger-grain option, perhaps at the root of the uiSchema, that adds all of the safety possible. What do you think about that? I understand it's a more invasive change, but I think it's a more holistic approach.

glasserc avatar Jan 10 '18 19:01 glasserc

Yeah, I like that. I'm currently involved more heavily in some other projects at the moment but when I circle back to the one where we're using rjsf I'll take a look at a more in depth change (unless someone beets me to it).

mfulton26 avatar Jan 10 '18 21:01 mfulton26