rjsf-team/react-jsonschema-form

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

Closed

#3833 aperta il 17 ago 2023

Vedi su GitHub
 (7 commenti) (0 reazioni) (1 assegnatario)TypeScript (2136 fork)batch import
any-one-all-ofbughelp wanted

Metriche repository

Star
 (13.175 star)
Metriche merge PR
 (Merge medio 2g 9h) (36 PR mergiate in 30 g)

Descrizione

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.

Guida contributor