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: formData change clear errorMessage #4429

Merged
merged 8 commits into from
Jan 9, 2025

Conversation

JinYuSha0
Copy link
Contributor

Reasons for making this change

fixes #4426

If this is related to existing tickets, include links to them as well. Use the syntax fixes #[issue number] (ex: fixes #123).

If your PR is non-trivial and you'd like to schedule a synchronous review, please add it to the weekly meeting agenda: https://docs.google.com/document/d/12PjTvv21k6LIky6bNQVnsplMLLnmEuypTLQF8a-8Wss/edit

Checklist

  • I'm updating documentation
  • 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 description of the PR
  • I'm adding a new feature
    • I've updated the playground with an example use of the feature

@JinYuSha0
Copy link
Contributor Author

formData change should behave the same as onChange method, I have implemented this

fix: merge errorSchema

fix: merge errorSchema
Copy link
Member

@heath-freenome heath-freenome left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JinYuSha0 Please update the CHANGELOG.md to add a new 5.24.0 section since you are adding a new feature to @rjsf/utils. And make the few suggested changes. Also, provide 100% unit tests for the getChangedFields() function.

Also, these unit test, when written, should help you fix the test failures that exist in your PR.

* const changedFields = getChangedFields(a, b);
* console.log(changedFields); // Output: ['age']
*/
export default function getChangedFields(a: any, b: any): string[] {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For better Typescript compatibility, unknown is preferred over any

Suggested change
export default function getChangedFields(a: any, b: any): string[] {
export default function getChangedFields(a: unknown, b: unknown): string[] {

Comment on lines 11 to 12
* @param {any} a - The first object, representing the original data to compare.
* @param {any} b - The second object, representing the updated data to compare.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param {any} a - The first object, representing the original data to compare.
* @param {any} b - The second object, representing the updated data to compare.
* @param a - The first object, representing the original data to compare.
* @param b - The second object, representing the updated data to compare.

Copy link
Contributor Author

@JinYuSha0 JinYuSha0 Jan 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'm done with this

@heath-freenome
Copy link
Member

@JinYuSha0 I just merged another fix to the method you are changing... Can you first check to see if that fix also fixes the issue you are attempting to fix with this PR? Thanks. If not, then rebase that change into your PR first.

@JinYuSha0
Copy link
Contributor Author

@heath-freenome

rjsf-issuse4

I pulled the latest commit in the main branch and executed build, it seems that this problem has not been solved, thank you very much for your attention to this issue.

git log --oneline
f5a24b25 (HEAD -> main, origin/main, origin/HEAD) Bug: schema with conditions where switching to then/else subschemas did not reflect the actual validation errors in the onChange event. (#4432)
c2a60d44 Bug: Issue with formData not updating when dependencies change (#4388)

@heath-freenome
Copy link
Member

@JinYuSha0 In that case, would you be willing to rebase your changes on the latest and deal with the conflicts so that we can get your fix in?

@heath-freenome
Copy link
Member

Also, it looks like your changes are breaking a core test. Can you investigate and fix?

@JinYuSha0
Copy link
Contributor Author

I fix the breaking core test

  1. change formData then error should be disappears.
  2. when formData is srting, deepEquals again

@heath-freenome heath-freenome merged commit b6c1825 into rjsf-team:main Jan 9, 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.

The errorMessage will not be cleared after the controlled Form formData changes
2 participants