Fix: Make slider handle decimal values #959
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
I'm a backend dev, likely, this solution is likely not optimal, feel free to make whatever change you see fit 😄
As reported over on the CMS tracker the sliders didn't handle decimal values umbraco/Umbraco-CMS#17546
This PR fixes this.
The fix is to "count" the amount of decimals in the step. I.E
0.1
has 1 decimal,0.15
has 2, and then round the value to this amount of digits.For the normal slider I round the numbers when they're generated, this is because in the render methods the step size is not available.
For the range slider the rounding happens in the render methods because the step size is available there.
Types of changes
Motivation and context
It doesn't work, see the linked issue
How to test?
I've added 2 stories to test, if you add these before this change you see weird behaviour.
Screenshots (if appropriate)
See issue