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: #3924 by preventing an undefined schema for fixed array items #3929

Merged
merged 1 commit into from
Oct 30, 2023

Conversation

heath-freenome
Copy link
Member

@heath-freenome heath-freenome commented Oct 28, 2023

Reasons for making this change

Fixes #3924 by defaulting to an empty object for the itemSchema when undefined
Fixes #3927 by fixing getSnapshotBeforeUpdate() added for the fix #1794

  • In @rjsf/core updated ArrayField's renderFixedArray() to default the itemSchema to an empty object if it is falsy
    • Updated the tests for ArrayField to verify the fix
    • Updated the getSnapshotBeforeUpdate() to diff the old and new props and to set the shouldUpdate prop if the old and new state differs
  • Updated CHANGELOG.md accordingly

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

… items

Fixes rjsf-team#3924 by defaulting to an empty object for the `itemSchema` when undefined
Fixes rjsf-team#3927 by fixing `getSnapshotBeforeUpdate()` added for the fix rjsf-team#1794
- In `@rjsf/core` updated `ArrayField`'s `renderFixedArray()` to default the `itemSchema` to an empty object if it is falsy
  - Updated the tests for `ArrayField` to verify the fix
  - Updated the `getSnapshotBeforeUpdate()` to diff the old and new props and to set the `shouldUpdate` prop if the old and new state differs
- Updated `CHANGELOG.md` accordingly
  - Also added entry for the fix for rjsf-team#3919
): { nextState: FormState<T, S, F>; shouldUpdate: true } | { shouldUpdate: false } {
if (!deepEquals(this.props.formData, prevProps.formData)) {
if (!deepEquals(this.props, prevProps)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for finding and fixing this

@heath-freenome heath-freenome merged commit d8efef8 into rjsf-team:main Oct 30, 2023
4 checks passed
@heath-freenome heath-freenome deleted the fix-3924 branch October 30, 2023 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants