-
Notifications
You must be signed in to change notification settings - Fork 47.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 uncontrolled input decimal point "chopping" on number inputs, and validation warnings on email inputs #7750
Conversation
Honestly, I'm a bit confused why React changes |
@yaycmyk I can confirm later today, but I believe it is to support an input changing from controlled to uncontrolled. I think this technically should raise a console warning from React, but there's definitely a test for it. I can dig in and explain more later today. |
@yaycmyk Yeah, I believe it's needed to allow this test to pass: |
Beyond that, unsure to to ping, but I'd love to get this through if possible. Anything I can do to help move this along? |
Yeah I was more commenting that the behavior and accompanying test may not actually make sense. Would love to get a collaborator's opinion like @zpao |
I've reviewed this (when it was part of #7359) and it looks decent to me, but I would like someone from the core team to give the OK here. |
@aweary Awesome. I feel like I've taken you down a rocky road with all of this, thank you for your help! |
81a9a75
to
54fe1b9
Compare
Upstreamed with master. |
Hello, is there a timeline for this PR to be merged and released? |
Any testing materials I can put together to help verify this fix? I'd really like this to ship too. |
Can you please provide a table of the browsers you tested, test cases, and the behavior before and after this change? |
54fe1b9
to
2df2023
Compare
To reproduce the issue, visit here: When, in Chrome, backspacing to This fix is hosted here: And here's the list of browsers (though Chrome is the only place this matters):
This table is a bit excessive, but at least I got an excuse to use the markdown table generator for Emacs 😀 🔌. Just to reiterate, this appears to be specific to Chrome. It happens because Chrome updates the value of a number input whenever the |
@nhunzaker I'm still seeing the issue on this page? |
@aweary Sorry :(. That was confusing. @gaearon how does this sound:
Too verbose? |
Ah, I misread 😄 I think this change is reasonable. It makes sense regardless not to set an attribute unless it's required. |
@nhunzaker Sounds great, there's never a verbose Chrome bug description. |
Done! Now if I can only figure out how to solve #7359 .... |
@gaearon look good to you? I think this is safe to merge 👍 |
Do it |
@aweary Please don't forget to tag the |
… validation warnings on email inputs (facebook#7750) * Only assign defaultValue if it has changed. * Improve comment about reason for defaultValue conditional assignment
This fix is stuck inside of #7359 until I can sort out the outstanding concerns around controlled inputs. Hopefully this is easier to merge and people can start using uncontrolled number inputs again!
Basically avoid assigning
defaultValue
unless you have to. This prevents Chrome's number inputs from dropping decimal places or clearing the input when typing3e
. As documented here: #7253 (comment)