Skip to content
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

Fix: Make slider handle decimal values #959

Merged
merged 4 commits into from
Nov 18, 2024

Conversation

nikolajlauridsen
Copy link
Contributor

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (minor updates related to the tooling or maintenance of the repository, does not impact compiled assets)

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

@nielslyngsoe
Copy link
Member

@nikolajlauridsen love it, thanks!

@nielslyngsoe nielslyngsoe merged commit 4b814df into v1/contrib Nov 18, 2024
9 of 11 checks passed
@nielslyngsoe nielslyngsoe deleted the v1/fix/make-slider-handle-decimals branch November 18, 2024 14:50
nielslyngsoe pushed a commit that referenced this pull request Nov 20, 2024
* Make slider handle decimal values
@nielslyngsoe nielslyngsoe added the bug Something isn't working label Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants