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: get first type if array #3897

Merged
merged 3 commits into from
Oct 10, 2023

Conversation

jroebu14
Copy link
Contributor

@jroebu14 jroebu14 commented Oct 8, 2023

Reasons for making this change

Fixes #3875

Specific schema type arrays break the form.

This happens because logic in SchemaField gets the first element in the type array and if it is e.g. string or number then it will render a field component here rather than an unsupported field component here which is what would happen if the first element was blah. However, further along in the code the getWidget function calls getSchemaType which does not attempt to get the first element in the type array so code execution doesn't fall into any of the conditionals and eventually this error is thrown.

The fix is to copy the logic in SchemaField for array types and ultimately attempt to render a field by selecting the first element in the type array.

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

@heath-freenome
Copy link
Member

@jroebu14 Can you please update the CHANGELOG.md to put the fix under 5.13.1 in @rjsf/core

@heath-freenome
Copy link
Member

@jroebu14 Can you resolve the conflict in the CHANGELOG.md?

CHANGELOG.md Outdated Show resolved Hide resolved
Signed-off-by: Jonathan Roebuck <[email protected]>
@jroebu14 jroebu14 force-pushed the fix-union-type-breaking-form branch from 67ecbb5 to d803902 Compare October 10, 2023 17:28
@jroebu14 jroebu14 force-pushed the fix-union-type-breaking-form branch from d803902 to 45c6d2e Compare October 10, 2023 17:29
@jroebu14
Copy link
Contributor Author

@jroebu14 Can you resolve the conflict in the CHANGELOG.md?

@heath-freenome no probs. Resolved!

CHANGELOG.md Outdated Show resolved Hide resolved
@heath-freenome heath-freenome merged commit 0589204 into rjsf-team:main Oct 10, 2023
4 checks passed
@jroebu14 jroebu14 deleted the fix-union-type-breaking-form branch October 11, 2023 06:39
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.

Specific invalid type breaks Form instead of rendering UnsupportedFieldTemplate
2 participants