Skip to content

Conditional select field on Group Arrays not working #122

@lomels

Description

@lomels

Hi, we're facing a potential bug, conditional select field seems not working on group arrays item:

{
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "companies": {
      "title": "Companies",
      "type": "array",
      "default": [],
      "x-jsf-presentation": {
        "inputType": "group-array",
        "addFieldText": "Add company"
      },
      "items": {
        "type": "object",
        "properties": {
          "company": {
            "title": "Select Company",
            "type": "string",
            "description": "Choose a company",
            "oneOf": [
              {
                "title": "Company1",
                "const": "company1_id"
              },
              {
                "title": "Company2",
                "const": "company2_id"
              }
            ],
            "x-jsf-presentation": {
              "inputType": "select",
              "placeholder": "jsf_select_company"
            }
          },
          "role": {
            "title": "Role",
            "description": "Choose a role based on the selected company",
            "oneOf": [],
            "x-jsf-presentation": {
              "inputType": "select",
              "placeholder": "jsf_select_roles"
            }
          }
        },
        "allOf": [
          {
            "if": {
              "properties": {
                "company": {
                  "const": "company1_id"
                }
              },
              "required": [
                "company"
              ]
            },
            "then": {
              "properties": {
                "role": {
                  "oneOf": [
                    {
                      "title": "admin",
                      "const": "admin"
                    },
                    {
                      "title": "user",
                      "const": "user"
                    }
                  ],
                  "x-jsf-presentation": {
                    "inputType": "select"
                  }
                }
              },
              "required": [
                "role"
              ]
            }
          }
        ],
        "required": [
          "company",
          "role"
        ]
      }
    }
  },
  "required": [
    "companies"
  ]
}

Trying this json in playground you can see that selecting company1 the Role selector doesn't show any options.
The problem seems to be with the group arrays object, using the same selectors without group arrays works correctly, as you can see with this json:

{
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "company": {
      "title": "Select Company",
      "type": "string",
      "description": "Choose a company",
      "oneOf": [
        {
          "title": "Company1",
          "const": "company1_id"
        },
        {
          "title": "Company2",
          "const": "company2_id"
        }
      ],
      "x-jsf-presentation": {
        "inputType": "select",
        "placeholder": "jsf_select_company"
      }
    },
    "role": {
      "title": "Role",
      "description": "Choose a role based on the selected company",
      "oneOf": [],
      "x-jsf-presentation": {
        "inputType": "select",
        "placeholder": "jsf_select_roles"
      }
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "company": {
            "const": "company1_id"
          }
        },
        "required": [
          "company"
        ]
      },
      "then": {
        "properties": {
          "role": {
            "oneOf": [
              {
                "title": "admin",
                "const": "admin"
              },
              {
                "title": "user",
                "const": "user"
              }
            ],
            "x-jsf-presentation": {
              "inputType": "select"
            }
          }
        },
        "required": [
          "role"
        ]
      }
    }
  ],
  "required": [
    "company",
    "role"
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfix in v1Is a bug in v0, but fixed in v1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions