-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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: add condition to pick correct schemas for fixed array items in topathschemainternal util #3916
fix: add condition to pick correct schemas for fixed array items in topathschemainternal util #3916
Conversation
|
||
const formData = { | ||
str: 'string', | ||
arr: [{ name: 'name1' }, 'name2'], |
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.
I'm wondering whether there should be a console.warn
or console.error
for this condition?
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.
I can see that toPathSchema
util is mostly used as a step to omit extra data. In that case should we warn the users about the omitted data?
element, | ||
_recurseList | ||
); | ||
} |
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.
For the moment, let's add a console.warn()
here to let users know that they have unhandled formData
. Which means we want to update the test below with a check that console.warn()
was called. This can be done with a jest.spyOn()
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.
Sure. Added a message. Let me know if there is a change required.
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.
@heath-freenome Should this log be moved up a level outside the for loop? We don't know how many items there will be in the array and if there are too many items, it might clutter the console.
Reasons for making this change
Fixes #3909.
Changes
toPathSchemaInternal
util. Theitems
property for these schemas are ofarray
type instead ofobject
. Because the condition for the array typeitems
was not present, the array type schema was being sent into the recursive function as the schema for the form data, which was not matching. Hence empty form data was being generated each time Form'sonChange
was being calledtoPathSchema
utilChecklist
npm run test:update
to update snapshots, if needed.