rjsf-team/react-jsonschema-form

$ref object pointing to oneOf list does not update form properly when changed

Fermée

#3 833 ouverte le 17 août 2023

 (7 commentaires) (0 réaction) (1 personne assignée)TypeScript (2 136 forks)batch import
any-one-all-ofbughelp wanted

Métriques du dépôt

Stars
 (13 175 étoiles)
Métriques de merge PR
 (Merge moyen 3j 17h) (32 PRs mergées en 30 j)

Description

Prerequisites

What theme are you using?

core

Version

5.x

Current Behavior

$ref objects pointing to objects with oneOf lists do not update properly when a user tries to change the value via dropdown.

Expected Behavior

The dropdowns should be updating properly when the user changes the value.

Steps To Reproduce

  1. Use the playground/schema below.
  2. Try to change the "Approved" dropdown to "Rejected".
  3. Note that the dropdown doesn't actually change.

Playground link: https://rjsf-team.github.io/react-jsonschema-form/#eyJmb3JtRGF0YSI6e30sInNjaGVtYSI6eyJ0aXRsZSI6Im9uZU9mIEV4YW1wbGUiLCJ0eXBlIjoib2JqZWN0IiwicHJvcGVydGllcyI6eyJzdGF0dXMiOnsiJHJlZiI6IiMvZGVmaW5pdGlvbnMvc3RhdHVzIn19LCJkZWZpbml0aW9ucyI6eyJzdGF0dXMiOnsidGl0bGUiOiJGaWVsZCBTdGF0dXMiLCJ0eXBlIjoib2JqZWN0Iiwib25lT2YiOlt7InRpdGxlIjoiQXBwcm92ZWQiLCJ0eXBlIjoib2JqZWN0In0seyJ0aXRsZSI6IlJlamVjdGVkIiwidHlwZSI6Im9iamVjdCIsInByb3BlcnRpZXMiOnsicmVhc29uIjp7InRpdGxlIjoiUmVqZWN0aW9uIFJlYXNvbiIsInR5cGUiOiJzdHJpbmcifX19XX19fSwidWlTY2hlbWEiOnt9LCJ0aGVtZSI6ImRlZmF1bHQiLCJsaXZlU2V0dGluZ3MiOnsic2hvd0Vycm9yTGlzdCI6InRvcCIsImV4cGVyaW1lbnRhbF9kZWZhdWx0Rm9ybVN0YXRlQmVoYXZpb3IiOnsiYXJyYXlNaW5JdGVtcyI6eyJwb3B1bGF0ZSI6InBvcHVsYXRlIiwibWVyZ2VFeHRyYURlZmF1bHRzIjpmYWxzZX0sImVtcHR5T2JqZWN0RmllbGRzIjoicG9wdWxhdGVBbGxEZWZhdWx0cyJ9LCJsaXZlVmFsaWRhdGUiOmZhbHNlfX0=

Schema:

{
  "title": "oneOf Example",
  "type": "object",
  "properties": {
    "status": {
      "$ref": "#/definitions/status"
    }
  },
  "definitions": {
    "status": {
      "title": "Field Status",
      "type": "object",
      "oneOf": [
        {
          "title": "Approved",
          "type": "object"
        },
        {
          "title": "Rejected",
          "type": "object",
          "properties": {
            "reason": {
              "title": "Rejection Reason",
              "type": "string"
            }
          }
        }
      ]
    }
  }
}

Environment

N/A?

Anything else?

The closest existing issues I could find to this are below, but none of them seem caused by the same problem as far as I can tell. In each of those cases, the dropdown text does update, whereas mine does not.

Guide contributeur