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

fix: programmatic validation removes previous errors if all data is now valid #3855

Merged

Conversation

raing3
Copy link
Contributor

@raing3 raing3 commented Sep 4, 2023

Reasons for making this change

Programatic validation doesn't clear the errors if the form has been changed from being invalid -> valid. This results in stale errors remaining.

Reproduction steps:

  1. With the following example form: https://rjsf-team.github.io/react-jsonschema-form/#eyJmb3JtRGF0YSI6e30sInNjaGVtYSI6eyJ0aXRsZSI6IkEgcmVnaXN0cmF0aW9uIGZvcm0iLCJkZXNjcmlwdGlvbiI6IkEgc2ltcGxlIGZvcm0gZXhhbXBsZS4iLCJ0eXBlIjoib2JqZWN0IiwicmVxdWlyZWQiOlsibmFtZSJdLCJwcm9wZXJ0aWVzIjp7Im5hbWUiOnsidHlwZSI6InN0cmluZyIsInRpdGxlIjoiTmFtZSJ9fX0sInVpU2NoZW1hIjp7fSwidGhlbWUiOiJkZWZhdWx0IiwibGl2ZVNldHRpbmdzIjp7Im5vSHRtbDVWYWxpZGF0ZSI6dHJ1ZSwic2hvd0Vycm9yTGlzdCI6InRvcCIsImV4cGVyaW1lbnRhbF9kZWZhdWx0Rm9ybVN0YXRlQmVoYXZpb3IiOnsiYXJyYXlNaW5JdGVtcyI6eyJwb3B1bGF0ZSI6InBvcHVsYXRlIiwibWVyZ2VFeHRyYURlZmF1bHRzIjpmYWxzZX0sImVtcHR5T2JqZWN0RmllbGRzIjoicG9wdWxhdGVBbGxEZWZhdWx0cyJ9fX0=
  2. Click the Programmatic "Validate" button, an error indicating name is required should appear.
  3. Fill in the name field.
  4. Click the Programmatic "Validate" button again.

Expected: The error should disappear after clearing invalid data and re-validating.
Actual: The error remains after clearing invalid data and re-validating.

Workaround:

Pass additional props when rendering Form so the state will still be updated if there are no errors:

        extraErrors={{}}
        extraErrorsBlockSubmit={true}

Checklist

  • I'm updating documentation
  • I'm adding or updating code
    • I've added and/or updated tests. I've run npm run test:update to update snapshots, if needed.
    • I've updated docs if needed
    • I've updated the changelog with a description of the PR
  • I'm adding a new feature
    • I've updated the playground with an example use of the feature

…esult value to ensure it returns appropriate success/fail result
@raing3 raing3 force-pushed the fix_programmatic_validation_bug branch from aaad9f5 to 0175c91 Compare September 4, 2023 21:51
@heath-freenome heath-freenome merged commit 2c279de into rjsf-team:main Sep 8, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants