Skip to content

fix(ui-number-input): preserve precision for small steps - #2401

Open
pcbeingused333 wants to merge 1 commit into
FlowFuse:mainfrom
pcbeingused333:fix/ui-number-input-small-step
Open

pcbeingused333 wants to merge 1 commit into
FlowFuse:mainfrom
pcbeingused333:fix/ui-number-input-small-step

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

The number input rounds values to zero for small steps such as 0.0000001 and can reject the decimal digits needed to enter them. JavaScript serializes that step as 1e-7, so counting only the digits after the decimal point gives Vuetify a precision of zero.

Calculate precision from the normalized step's coefficient and exponent, within the range accepted by toFixed(). Steps of 1e-7 and 1.25e-7 now use seven and nine decimal places, respectively.

The Mocha regression test covers decimal and scientific notation and verifies that formatting with toFixed() preserves a step of 0.0000001. Four cases fail with the previous calculation, and all eight pass with the fix. Run it with npx mocha test/ui/number-input-precision.spec.js.

This change was prepared with AI assistance.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant