-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Add null checks for ArrayField (New PR for #1553) #1992
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
Conversation
Hi @richmahn is that PR still valid? @epicfaace do you think that this PR could be merged? |
wanted to bump this PR, commented on the original issue: #1346 (comment) - let me know if I can assist in getting this through at all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating the PR! I'm a bit confused about what exactly the logic of the additions is -- when exactly would keyedFormData
be equal to null
? Wouldn't it always be equal to []
if the form data itself is equal to null
? (see
react-jsonschema-form/packages/core/src/components/fields/ArrayField.js
Lines 184 to 193 in a4f6c1f
function generateKeyedFormData(formData) { | |
return !Array.isArray(formData) | |
? [] | |
: formData.map(item => { | |
return { | |
key: generateRowId(), | |
item, | |
}; | |
}); | |
} |
@epicfaace The keyDataValue being null happens whenever the json file has a null, such as:
Before it was only allowing it to be I have no idea why it is failing to build/deploy. Says that |
@epicfaace I did investigate it further and as you are right that Another thing (could be separate issue) is if you set the type to nullable it won't work, it will crash the same way. But in this case I would assume that nullable check should happen eariler and it should not even enter ArrayField component. I wanted to mention that there are other issues opened that seems to be related to this one: #1957, #282, #2153 |
Ah, I see. So do you think a better solution might be to instead modify react-jsonschema-form/packages/core/src/components/fields/ArrayField.js Lines 222 to 245 in 49e9184
|
Ah, wait, I see that this PR (#2154) actually does exactly that! If you're good with it, I think we should merge that one instead of this one. |
@epicfaace I would not be hurt in the least if you did that. Haha |
@epicfaace Yeah, just tested it and it seems to work. Just as a side note, atm if I'll provide null value with type |
Thanks for the explanation @ri0ter . I'll close this issue in favor of #2154, and close out some of these other related issues. With the other PR, I did notice a minor issue with nullable arrays; I'm cataloguing it in #2212.
Could you make this into a separate issue so we could address it later? |
This is a new PR to replace PR #1553 since that PR's author is no longer responding. Resolves conflicts.