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

NumericInput up/down keypress/button click breaks on stepsize smaller than 0.001 #4497

Closed
cybae0804 opened this issue Jan 26, 2021 · 4 comments · Fixed by #6382
Closed

NumericInput up/down keypress/button click breaks on stepsize smaller than 0.001 #4497

cybae0804 opened this issue Jan 26, 2021 · 4 comments · Fixed by #6382

Comments

@cybae0804
Copy link
Contributor

Environment

  • Package version(s): @blueprintjs/core: "3.38.1"
  • Operating System: Ubuntu 20.04 LTS
  • Browser name and version: Chrome 87.0.4280.141

Code Sandbox

https://codesandbox.io/s/blueprint-sandbox-forked-98i26

Steps to reproduce

Provide a stepSize and minorStepSize such as 0.0001, and try to modify the input using the up/down button or the keypress. It will lock up and won't fire onValueChange correctly.

Actual behavior

Freezes

Expected behavior

Increments/Decrements value correctly

Possible solution

Tried to investigate a bit but couldn't figure it out. The count decimals util function seems to be working correctly however.

@tonooo71
Copy link
Contributor

I'm using the v4.0.0-alpha version and I also encountered the same bug.

I think the cause of this bug is num.toLocaleString(locale) in the toLocaleString function of numericInputUtils.ts.
The numeric string obtained by num.toLocaleString(locale) is truncated to the fourth decimal place.
Number.prototype.toLocaleString(): MDN

So, for example, by using num.toLocaleString(locale, { maximumSignificantDigits: 10 }), I think the number up to the tenth decimal place will work on NumericInput.

@SquareByte
Copy link

Issue still exists in v5.0.0

@Rafael-Martins
Copy link
Contributor

I'm using the v4.0.0-alpha version and I also encountered the same bug.

I think the cause of this bug is num.toLocaleString(locale) in the toLocaleString function of numericInputUtils.ts. The numeric string obtained by num.toLocaleString(locale) is truncated to the fourth decimal place. Number.prototype.toLocaleString(): MDN

So, for example, by using num.toLocaleString(locale, { maximumSignificantDigits: 10 }), I think the number up to the tenth decimal place will work on NumericInput.

Opened a pr based on this solution, but I'm not assured why this is happening 🤔 I will do more investigation tomorrow, but, the solution is working and I wrote some tests to cover it

@TheRayTracer
Copy link

Does this also resolve?: #4045

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

6 participants