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

[#9712] fix <input type="number" /> value '.98' should not be equal to '0.98'. #9714

Merged
merged 3 commits into from
Jun 9, 2017

Conversation

pingan1927
Copy link
Contributor

@pingan1927 pingan1927 commented May 18, 2017

fix bug #9712

I found in 15.5.4 is NOT OK, but in 16.0.0-alpha.3 is ok.
In 16.0.0-alpha.3 the number type is not handled separately.

15.5.4 is NOT OK

16.0.0-alpha.3 is OK

the change is base on master. Maybe the pr is worth to accept.

@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks!

If you are contributing on behalf of someone else (eg your employer): the individual CLA is not sufficient - use https://developers.facebook.com/opensource/cla?type=company instead. Contact cla@fb.com if you have any questions.

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@nhunzaker
Copy link
Contributor

Awesome. @pingan1927 thanks so much for putting this together! I'll have some time later today or tomorrow morning to give it a thorough review.

Thanks again for sending this out!

@pingan1927
Copy link
Contributor Author

I think the code after fixed from v15.5.4 is better than v16.0.0-alpha3. It can reduce the render times if the input type is number.
My job code need set the input type to number to trigger a custom keyboard in some App.
The Test engineer ask me to format eg '.98' to '0.98' if the user input it to avoid some confuse. But I can't do it now.
So, can you give me some solution to make the change '.98' to '0.98' work in React 15.5.4 or older version?

@pingan1927
Copy link
Contributor Author

@nhunzaker you forgot this PR?

@nhunzaker
Copy link
Contributor

@pingan1927 Sorry. Busy time... thanks for the ping. Checking it out now.

@@ -158,6 +159,20 @@ function NumberInputs() {
</TestCase.ExpectedResult>
<NumberTestCase />
</TestCase>
<TestCase
title="decimal numbers"
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: Could you capitalize "Decimal"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have fixed it. Any Problem?

Copy link
Contributor

@nhunzaker nhunzaker left a comment

Choose a reason for hiding this comment

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

This looks good. My only outstanding concern is that it is possible that this is fixed on the 15.6-dev branch, which has related commits from 16-alpha:

https://github.com/facebook/react/blob/15.6-dev/src/renderers/dom/client/wrappers/ReactDOMInput.js#L216-L233

Either way, you've added an important tests/fixtures that I want to merge into the test suite.

So for next steps:

  • Let's figure out if the 15.6-dev branch exhibits the incorrect behavior.
  • If the upcoming 15.6 release works as intended, revert the ReactDOMInput changes, but let's keep the tests/fixtures
  • If 15.6 is not correct, let's figure out what needs to get sent over from master to address the fix.

I'm in the middle of a location move, so my availability isn't the best, but I will do my best to follow up later this week.

@aweary
Copy link
Contributor

aweary commented Jun 7, 2017

I tested with the 15.6 RC and verified that this is still broken there. Testing locally, this should also fix #9884. @nhunzaker I think we should move on this quickly so we can include it in 15.6.

@nhunzaker
Copy link
Contributor

@aweary Thanks for digging into that! Okay, cool. I put up a build here:
http://react-9714.surge.sh/number-inputs

This checks out for me. 👍

@pingan1927
Copy link
Contributor Author

@nhunzaker So what should I do next?

@nhunzaker nhunzaker merged commit 8ab56e5 into facebook:master Jun 9, 2017
@nhunzaker
Copy link
Contributor

@pingan1927 Nothing, this is great work! I did more testing on Chrome, Safari, Firefox, and IE11. Everything behaves as expected.

Let's get this on 15.6. Great work, @pingan1927! Thank you for your patience.

@gaearon
Copy link
Collaborator

gaearon commented Jun 9, 2017

cc @flarnie

@flarnie
Copy link
Contributor

flarnie commented Jun 9, 2017

@nhunzaker feel free to cherry-pick or merge to 15.6-dev if you didn't already, or I can do it in the morning. Awesome to see this fixed so fast. :)

flarnie pushed a commit to flarnie/react that referenced this pull request Jun 12, 2017
… equal to '0.98'. (facebook#9714)

* [facebook#9712] fix <input type="number" /> value ".98" should not be equal to "0.98".

* fix eslint error

* fix label error
flarnie added a commit that referenced this pull request Jun 12, 2017
…o '0.98'. (#9714) (#9929)

* [#9712] fix <input type="number" /> value ".98" should not be equal to "0.98".

* fix eslint error

* fix label error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants