Skip to content

nested allOf if condition is met when the form first loads even though value does not match the condition  #4400

@dagda1

Description

@dagda1

Prerequisites

What theme are you using?

mui

Version

5.23.1

Current Behavior

You can see when this playground first loads that this field is visible

aaa

This should only be visible when the previous dropdown Please specify Affiliates has a value of Other which is in a nested "allOf" field

"allOf": [
  {
    "if": {
      "properties": {
        "Is this request for an affiliate ?": {
          "const": "true"
        }
      }
    },
    "then": {
      "properties": {
        "[\"Please specify Affiliates\"]": {
          "title": "Please specify Affiliates",
          "type": "string",
          "enum": [
            "Partner Solutions Inc",
            "Cime",
            "Royal Sun Alliance",
            "Intact Public Entities",
            "Coast",
            "Intact Specialty Lines",
            "On Side restoration",
            "Other"
          ],
          "default": "Cime"
        }
      },
      "required": [
        "[\"Please specify Affiliates\"]"
      ],
      "allOf": [
        {
          "if": {
            "properties": {
              "[\"Please specify Affiliates\"]": {
                "const": "Other"
              }
            }
          },
          "then": {
            "properties": {
              "[\"Please provide the other affiliate's company name\"]": {
                "title": "Please provide the other affiliate's company name",
                "type": "string",
                "default": ""
              }
            },
            "required": [
              "[\"Please provide the other affiliate's company name\"]"
            ]
          }
        }
      ]

If I then select a value other than Other, the input disappears unless I select Other again, which is the correct behaviour. So, the problem is when the form first loads.

Hopefully, this video shows what I mean

aaaa.mp4

Do you know if this is a bug?

Expected Behavior

The if condition in the nested allOf should not be met when the form first loads.

Steps To Reproduce

The Please provide the other affiliate's company name* should not be visible when the form first loads in this playground

Environment

- OS:
- Node:
- npm:

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds triageInitial label given, to be assigned correct labels and assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions