rjsf-team / react-jsonschema-form

A React component for building Web forms from JSON Schema.
https://rjsf-team.github.io/react-jsonschema-form/
Apache License 2.0
14.12k stars 2.18k forks source link

OneOf with array as subschema is failling with any rjsf theme #2375

Open Ugolaf opened 3 years ago

Ugolaf commented 3 years ago

Prerequisites

shared playground link of bug

Description

I'm trying to have a multiple-choice select with a dependency for one or more values.

There are 3 choices: A, B, or C. So there is exactly 7 differents possibilities + the empty possibility: A B C A, B A, C B, C A, B, C

Dependencies are working but if you select C then B within a theme (for example material UI theme), oneOf is failing because he doesn't match to [B, C] because its value is [C, B].

Steps to Reproduce

  1. Go to shared playground link of bug
  2. Open log in your browser
  3. Select C then B

Expected behavior

As it's happening without a specific theme on rjsf, [C, B] will match to [B, C] array.

Actual behavior

ignoring oneOf in dependencies because there isn't exactly one subschema that is valid

[C, B] is different from [B, C] for oneOf. It must match if the array contains the same things. Or it will be really heavy for A, B, C choice to define oneOf 14 possibilities for that example :
A B C A, B B, A A, C C, A B, C C, B A, B, C B, A, C B, C, A C, B, A C, A, B

I also tried to reorder the formdata array but the error is happening before onChange trigger.

Version

"@rjsf/core": "^2.5.1", "@rjsf/material-ui": "^2.5.1",

xyy7260 commented 3 years ago

@Ugolaf I also encountered this problem, did you solve it in the end? But I need to choose ['a','b','c'] then a, b, and c must appear at the same time