rjsf-team/react-jsonschema-form

Nested `if` / `else` support is flaky when using `enums`

Open

#3.618 aberto em 21 de abr. de 2023

Ver no GitHub
 (3 comments) (0 reactions) (0 assignees)TypeScript (2.136 forks)batch import
bughelp wantedif-then-else

Métricas do repositório

Stars
 (13.175 stars)
Métricas de merge de PR
 (Mesclagem média 3d 17h) (32 fundiu PRs em 30d)

Description

Prerequisites

What theme are you using?

core

Version

5.x

Current Behavior

With this schema:

{
  "type": "object",
  "properties": {
    "type": {
      "enum": [
        "list-select",
        "empty",
        "static"
      ]
    }
  },
  "if": {
    "properties": {
      "type": {
        "const": "static"
      }
    }
  },
  "then": {
    "properties": {
      "value": {
        "type": "string"
      }
    }
  },
  "else": {
    "if": {
      "properties": {
        "type": {
          "const": "list-select"
        }
      }
    },
    "then": {
      "properties": {
        "id": {
          "enum": []
        }
      }
    }
  }
}

the value string field won't render. If you change the "enum": [] line to something else let's say: "type": "string" then it works.

Expected Behavior

I would have expected it to work either way, although if it didn't work in both cases that would be better than what it is now IMO

Steps To Reproduce

Working Not Working

Select static on both examples and you will see that the value field gets rendered in one but not the other.

Environment

- OS: MacOS
- Browser: Arc

Anything else?

No response

Guia do colaborador