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

Cannot use 'in' operator to search for '$ref' in undefined in fixed arrays #3924

Closed
4 tasks done
A11oW opened this issue Oct 27, 2023 · 0 comments · Fixed by #3929
Closed
4 tasks done

Cannot use 'in' operator to search for '$ref' in undefined in fixed arrays #3924

A11oW opened this issue Oct 27, 2023 · 0 comments · Fixed by #3929

Comments

@A11oW
Copy link

A11oW commented Oct 27, 2023

Prerequisites

What theme are you using?

core

Version

5.13.2

Current Behavior

If I use fixed Array and provide extended data in formData props I get exception: "Cannot use 'in' operator to search for '$ref' in undefined"

For example:

JSONSchema:

{
  "type": "object",
  "properties": {
    "scoreEntries": {
      "type": "array",
      "items": [
        {
          "properties": {
            "scorePercent": {
              "type": "number"
            }
          }
        }
      ]
    }
  }
}

formData:

{
  "scoreEntries": [
    {
      "scorePercent": 10032
    },
    {
      "scorePercent": 10032
    }
  ]
}

And if I remove last item from formData array, then this work good

Expected Behavior

When passing additional data in formData, ignore it and proxy it to the submit

Steps To Reproduce

No response

Environment

- OS: Ubuntu 20.04
- Node: 20.5.0
- npm: 9.8.1

Anything else?

Playground

@A11oW A11oW added bug needs triage Initial label given, to be assigned correct labels and assigned labels Oct 27, 2023
A11oW pushed a commit to A11oW/react-jsonschema-form that referenced this issue Oct 28, 2023
A11oW pushed a commit to A11oW/react-jsonschema-form that referenced this issue Oct 28, 2023
heath-freenome added a commit to heath-freenome/react-jsonschema-form that referenced this issue Oct 28, 2023
… items

Fixes rjsf-team#3924 by defaulting to an empty object for the `itemSchema` when undefined
- 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 `CHANGELOG.md` accordingly
  - Also added entry for the fix for rjsf-team#3919
@heath-freenome heath-freenome added arrays and removed needs triage Initial label given, to be assigned correct labels and assigned labels Oct 28, 2023
heath-freenome added a commit to heath-freenome/react-jsonschema-form that referenced this issue Oct 28, 2023
… 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
heath-freenome added a commit to heath-freenome/react-jsonschema-form that referenced this issue Oct 28, 2023
… 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
heath-freenome added a commit to heath-freenome/react-jsonschema-form that referenced this issue Oct 28, 2023
… 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
heath-freenome added a commit that referenced this issue Oct 30, 2023
…3929)

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
  - Also added entry for the fix for #3919
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants