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

[RFR] Fix Forms Remove Empty Values #3758

Merged
merged 1 commit into from
Oct 2, 2019
Merged

[RFR] Fix Forms Remove Empty Values #3758

merged 1 commit into from
Oct 2, 2019

Conversation

djhi
Copy link
Contributor

@djhi djhi commented Oct 1, 2019

Supersedes #3656
Fixes #3551, #3660

@djhi djhi added this to the 3.0.0 milestone Oct 1, 2019
@djhi djhi mentioned this pull request Oct 1, 2019
Comment on lines +18 to +23
if (typeof values[key] === 'object' && values[key] !== null) {
acc[key] = sanitizeEmptyValues(initialValues[key], values[key]);
} else {
acc[key] =
typeof values[key] === 'undefined' ? '' : values[key];
}
Copy link
Contributor

Choose a reason for hiding this comment

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

As far as I understand you consider 3 cases:

  • values[key] is undefined, in that case you initialize the value with ""
  • values[key] is a non-null object, and you recursively sanitarize the values
  • in all other cases, the value is kept as it is
    I think you should also test that initialValues[key]!==null otherwise a recursive call may occurs and throw an error (Object.keys(null) is not defined)
    Furthermore, if value[key]===nulll you keep the null value, is that the wanted behavior ?

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.

None yet

3 participants