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

Bug: schema with conditions where switching to then/else subschemas did not reflect the actual validation errors in the onChange event. #4432

Merged

Conversation

abdalla-rko
Copy link
Contributor

@abdalla-rko abdalla-rko commented Dec 26, 2024

Reasons for making this change

Fixes #4249

Additional improvement

The ajv.compile method is costly in terms of performance when it has to recompile on onChange or on props change. To improve this we now provide the same retrievedSchema (by reference) unless it changes in which case we provide a new retrievedSchema. This ensures that AJV retrieves the schema from the cache unless the retrievedSchema content changes then it will recompile.

I've run the test with a very large schema(link attached) the compile used to take 640ms and now it takes 40ms. You can see the performance improvement if you load the link in the attached file in the main branch and compare it to this feature branch. You'll notice by typing in any field that it is massively slow on the main branch.
rjsf-playground-link (2).txt

Checklist

  • I'm adding or updating code
    • I've added and/or updated tests. I've run npx nx run-many --target=build --exclude=@rjsf/docs && npm run test:update to update snapshots, if needed.
    • I've updated docs if needed
    • I've updated the changelog with a

…en/else subschemas did not reflect the actual validation errors in the onChange event.
packages/core/src/components/Form.tsx Outdated Show resolved Hide resolved
packages/core/src/components/Form.tsx Outdated Show resolved Hide resolved
@heath-freenome heath-freenome merged commit f5a24b2 into rjsf-team:main Jan 6, 2025
5 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.

Live validation / onChange errors issue
2 participants