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

Avoid validation warning when inputs change type #7333

Merged
merged 1 commit into from
Jul 23, 2016

Conversation

nhunzaker
Copy link
Contributor

For controlled inputs, updateWrapper was getting called before the type prop had a chance to update. This could lead to a case where switching from the text to number type caused a validation error that would prevent the proper input value from being assigned.

This commit moves the call to ReactDOMInput.updateWrapper below _updateProperties to avoid this situation.

Fixes #6441.

Also worth mentioning: this does not fix #7144. It looks like Safari still doesn't like it when you change an input's type to file; period. That may require using a key, as others have suggested.

@sophiebits
Copy link
Collaborator

Can we move textarea down too for consistency? And let's make it a switch for input/select/textarea.

For controlled inputs, `updateWrapper` was getting called before the
`type` prop had a chance to update. This could lead to a case where
switching from the `text` to `number` type caused a validation error
that would prevent the proper input value from being assigned.

This commit moves the call to `ReactDOMInput.updateWrapper` below
`_updateProperties` to avoid this situation.
@nhunzaker
Copy link
Contributor Author

Done. I think this can also be patched right into 15-stable.

@sophiebits sophiebits added this to the 15-next milestone Jul 23, 2016
@sophiebits sophiebits merged commit 08a0895 into facebook:master Jul 23, 2016
@sophiebits
Copy link
Collaborator

Perfect, thanks!

@ghost ghost added the CLA Signed label Jul 23, 2016
@zpao zpao modified the milestones: 15.3.1, 15-next Aug 12, 2016
zpao pushed a commit that referenced this pull request Aug 12, 2016
For controlled inputs, `updateWrapper` was getting called before the
`type` prop had a chance to update. This could lead to a case where
switching from the `text` to `number` type caused a validation error
that would prevent the proper input value from being assigned.

This commit moves the call to `ReactDOMInput.updateWrapper` below
`_updateProperties` to avoid this situation.
(cherry picked from commit 08a0895)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants