Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
4 tasks done
donalddalton opened this issue Nov 1, 2024 · 1 comment
Open
4 tasks done

Comments

@donalddalton
Copy link

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

@donalddalton donalddalton added bug needs triage Initial label given, to be assigned correct labels and assigned labels Nov 1, 2024
@donalddalton donalddalton changed the title Unexpected behavior when conditionally including fields with defaults inside of if-then-else Unexpected behavior when conditionally including fields if-then-else Nov 1, 2024
@donalddalton donalddalton changed the title Unexpected behavior when conditionally including fields if-then-else Unexpected behavior when conditionally including fields with if-then-else Nov 1, 2024
@heath-freenome
Copy link
Member

@donalddalton Have you tried using the omitExtraData and liveOmit features? This playground show it works

@heath-freenome heath-freenome added question awaiting response and removed bug needs triage Initial label given, to be assigned correct labels and assigned labels Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants