Skip to content

Unexpected behavior when conditionally including fields with if-then-elseΒ #4362

@donalddalton

Description

@donalddalton

Prerequisites

What theme are you using?

mui

Version

5.x

Current Behavior

I have a schema with a top-level boolean property (called parent) which is used to conditionally add another property with a default value (called child) via an if-then-else statement. RJSF correctly shows/hides child based on the value of parent, however, the default value of child is always included in form data.

Similarly, in the case where child does not have a default and you:

  1. set parent=true
  2. input a value for child
  3. set parent=false

The child field is hidden in the form but the value is still included in form data.

Expected Behavior

That the value of child is conditionally included/excluded from form data.

Steps To Reproduce

Check out this playground example recapitulating the scenario above. Notice how the value of child is included in form data regardless of the value of parent.

Environment

- OS: Ubuntu
- Node: 18

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions