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

Creating a dependency for an element marked as "required" does not remove the element from the array of required fields #172

Open
ssmithereens opened this issue Aug 19, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@ssmithereens
Copy link
Contributor

If you create a form with elements newInput1 and newInput2 (both with input type short answer) and mark newInput2 as a required field, the resulting schema is:

{ type: 'object', properties: { newInput1: { title: 'New Input 1', type: 'string' }, newInput2: { title: 'New Input 2', type: 'string' } }, dependencies: {}, required: [ 'newInput2' ] }

If you then create a dependency for newInput1 so that if it shows newInput2 if newInput1 has any value, the following schema is produced:

{ type: 'object', properties: { newInput1: { title: 'New Input 1', type: 'string' } }, dependencies: { newInput1: { properties: { newInput2: { title: 'New Input 2', type: 'string' } }, required: [ 'newInput2' ] } }, required: [ 'newInput2' ] }

newInput2 is incorrectly still set as a required field in the parent required fields array, which means that the form can't be successfully submitted by the user. The validation error '.newInput2 is a required property' is triggered, even though newInput2 is only conditionally shown if newInput1 has a value.

Expected behaviour: newInput2 should be removed from the parent required fields array, since it is a dependent field.

@raymond-lam raymond-lam added the bug Something isn't working label Aug 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants