spectrum-web-components
spectrum-web-components copied to clipboard
[Bug]: Precision error in sp-number-field with decimal step increments
trafficstars
Code of conduct
- [X] I agree to follow this project's code of conduct.
Impacted component(s)
sp-number-field
Expected behavior
When using arrow keys or a mouse scroll wheel to increment the value is to adjust the value in steps exactly as defined by the 'step' attribute.
Actual behavior
Value is experiencing floating-point precision issues. When the value is adjusted via the arrow keys or mouse scroll wheel, and the step is set to a decimal, the resulting value displays excessive decimal places, such as "0.00100000000...".
Screenshots
What browsers are you seeing the problem in?
Chrome
How can we reproduce this issue?
- https://opensource.adobe.com/spectrum-web-components/storybook/?path=/story/number-field--default&args=value:0.001
- Set 'step' attribute value to a decimal value (e.g., '0.001').
- Use the arrow keys or mouse scroll wheel to increment or decrement the value. Observe that the displayed value shows more decimal places than expected (e.g., "0.0019999999999" instead of "0.001").
Sample code that illustrates the problem
No response
Logs taken while reproducing problem
No response
Hi @johncabang , can you confirm whether this is still happening on the latest version of storybook for you? I'm not able to reproduce.