-
Notifications
You must be signed in to change notification settings - Fork 2.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
Surprising rounding in NumericalInput #4045
Comments
I have experienced the same undesired behavior with the NumericalInput component when attempting to make input forms for scientific computing. Blueprint core version: For example, when props are:
Values are rounded up or down, and seems impossible to have a value such as 0.0001 without the value being rounded down to 0 on blur. I have traced this behavior to the following: It seems that the NumericalInput component is preforming rounding on the input in addition to just clamping the number. There is most likely a logical and sound reason for this, however, this behavior is not documented with the It further seems that the component attempts to offer some control around this rounding feature via the Possible solutions:
|
fixed by #6382 |
On
blueprintjs/[email protected]
and withminorStepSize
property set to1e-20
I'm seeing an unintuitive behaviour withNumericInput
:upon blurring the input some numbers are being rounded, while some are not:
2, 20, 200
would not get “sanitized” to a different value2000
->1999.9999999999998
20000
would not get sanizited200000
->200000.00000000003
2000000, 20000000
would not get sanizitedbut
200000000
would have same decimal part as 2000 after clamping etc…is it perhaps something with the rounding / max step precision logic in https://github.com/palantir/blueprint/blob/develop/packages/core/src/components/forms/numericInput.tsx#L218 and https://github.com/palantir/blueprint/blob/develop/packages/core/src/components/forms/numericInputUtils.ts#L91 ?
My props:
the rounded numbers above have been collected from
this.updateNumber
fromvalueAsNumber
param (no difference between it andvalueAsString
).Property documentation pasted below does not mention that
minorStepSize
is being used at all to derive precision of the input or/and rounding logic applied:The text was updated successfully, but these errors were encountered: