react-jsonschema-form icon indicating copy to clipboard operation
react-jsonschema-form copied to clipboard

IfThenElse showing property behind "IF", even when condition is not true

Open peterbartels opened this issue 1 year ago • 1 comments

Prerequisites

What theme are you using?

core

Version

5.x

Current Behavior

When making a conditional property using the IfThenElse in an allOf and this property is not set (and also doesn;t validate the IF condition), it's still being shown.

In the minimal playground example, the "food" item is behind an if when animal: true - but the item is still shown when no animal is chosen by default

Expected Behavior

A property behind IF should not be shown by default

Steps To Reproduce

See this playground link

Environment

No response

Anything else?

No response

peterbartels avatar Sep 30 '24 17:09 peterbartels

This is not a bug. The condition "required": [ "animal" ] needs to be in the if block if you want it to only be true when animal is not null.

Here is the changed schema in the playground.

nickgros avatar Oct 04 '24 19:10 nickgros

Closing as the solution was provided

heath-freenome avatar Nov 21 '25 20:11 heath-freenome