Description
Provide a general summary of the issue here
NumberField decrease/increase buttons are not decreasing/increasing value as expected when step is small due to JS transforming step into exponential notation.
🤔 Expected Behavior?
Even when step is small, decrease/increase should work.
😯 Current Behavior
After clicking a couple of times on increase/decrease button, value gets stuck and doesn't increase/decrease anymore.
💁 Possible Solution
Change implementation of roundToStepPrecision function to support exponential notation of numbers.
https://github.com/adobe/react-spectrum/blob/main/packages/%40react-stately/utils/src/number.ts#L24
🔦 Context
console.log(0.0000001) // 1e-7
console.log(0.000001) // 0.000001
🖥️ Steps to Reproduce
Click on the increase or decrease button multiple times. Notice how at some point it's not possible to increase/decrease anymore.
https://codesandbox.io/p/devbox/patient-haze-938prj?workspaceId=ws_WLQRjyxzXR8tUrnqkcKLtT
Version
3.42
What browsers are you seeing the problem on?
Chrome
If other, please specify.
No response
What operating system are you using?
MacOS
🧢 Your Company/Team
No response
🕷 Tracking Issue
No response
Activity
LFDanLu commentedon May 21, 2025
Thanks for catching this! We can look at processing exponential notation and figuring out the equivalent amount of precision, guess it would just be looking to see if
pointIndex
is resolving to exponential notation with a negative power, taking that power and adding one to its absolute value (e.g. 1e-7 ->precision
of 8)