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

Long decimals from slider value when steps are .1 #10951

Closed
nateclicks opened this issue Apr 23, 2018 · 5 comments · Fixed by #10959
Closed

Long decimals from slider value when steps are .1 #10951

nateclicks opened this issue Apr 23, 2018 · 5 comments · Fixed by #10959
Assignees
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@nateclicks
Copy link

Bug, feature request, or proposal:

Bug

What is the expected behavior?

The value displayed in the from to be only 1 decimal when using 1 decimal steps

What is the current behavior?

Sometimes it is one decimal, sometimes it is many more.
image

image

This can also be observed in the Material Angular documentation
image

What are the steps to reproduce?

  1. Create a slider
  2. Create a text box
  3. Set the slider steps to .1
  4. Bind the value of the slider to the textbox
  5. Slide the slider around
  6. Observe intermittent issues with long decimals

Editor URL: https://stackblitz.com/edit/angular-material2-example
App URL: https://angular-material2-example.stackblitz.io

What is the use-case or motivation for changing an existing behavior?

The existing behavior seems incorrect.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Angular 5.2.8
Material 5.2.5

Is there anything else we should know?

It looks there have been attempts to address this in other areas like the thumb label. Not sure if it has come back or just never got fully addressed or if there is just something I am doing wrong.
Previous issue: #2511 , #2527

@nateclicks nateclicks changed the title Long decimals in slider Long decimals from slider value when steps are .1 Apr 23, 2018
@crisbeto crisbeto self-assigned this Apr 23, 2018
@crisbeto crisbeto added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent has pr labels Apr 23, 2018
crisbeto added a commit to crisbeto/material2 that referenced this issue Apr 23, 2018
When a slider has a decimal step, we can end up with a value being assigned to the model that looks like 33.300000000000004. These changes ensure that the value is rounded to the same amount of decimals as the step.

Fixes angular#10951.
andrewseguin pushed a commit that referenced this issue Apr 26, 2018
When a slider has a decimal step, we can end up with a value being assigned to the model that looks like 33.300000000000004. These changes ensure that the value is rounded to the same amount of decimals as the step.

Fixes #10951.
@H3llK33p3r
Copy link

Hi with the new angular/material stack the issue is fixed for mouse event but not keybord. Try with the previous example with new angular stack : https://stackblitz.com/edit/angular-material6-example?file=app/app.component.html

Use keyboard arrow you will see the same kind of problem.

crisbeto added a commit to crisbeto/material2 that referenced this issue May 30, 2018
…step

When incrementing a slider using the keyboard, the value can end up looking like
33.300000000000004, if the consumer set a decimal step. We fixed this a while ago for dragging, but that didn't cover the keyboard interactions. These changes move the logic from the earlier fix so it can apply everywhere.

Relates to angular#10951.
@crisbeto
Copy link
Member

Thanks for the heads-up @H3llK33p3r, I've submitted #11574 to sort it out.

andrewseguin pushed a commit that referenced this issue Jun 5, 2018
…step

When incrementing a slider using the keyboard, the value can end up looking like
33.300000000000004, if the consumer set a decimal step. We fixed this a while ago for dragging, but that didn't cover the keyboard interactions. These changes move the logic from the earlier fix so it can apply everywhere.

Relates to #10951.
andrewseguin pushed a commit that referenced this issue Jun 7, 2018
…step

When incrementing a slider using the keyboard, the value can end up looking like
33.300000000000004, if the consumer set a decimal step. We fixed this a while ago for dragging, but that didn't cover the keyboard interactions. These changes move the logic from the earlier fix so it can apply everywhere.

Relates to #10951.
andrewseguin pushed a commit that referenced this issue Jun 7, 2018
…step (#11574)

When incrementing a slider using the keyboard, the value can end up looking like
33.300000000000004, if the consumer set a decimal step. We fixed this a while ago for dragging, but that didn't cover the keyboard interactions. These changes move the logic from the earlier fix so it can apply everywhere.

Relates to #10951.
andrewseguin pushed a commit that referenced this issue Jun 8, 2018
…step (#11574)

When incrementing a slider using the keyboard, the value can end up looking like
33.300000000000004, if the consumer set a decimal step. We fixed this a while ago for dragging, but that didn't cover the keyboard interactions. These changes move the logic from the earlier fix so it can apply everywhere.

Relates to #10951.
@alexciurea
Copy link

alexciurea commented Jul 7, 2018

hassio 0.73.0 - this is still a problem, even using the mouse.

my 2 input_numbers are defined in input_number.yaml

the High slider has this bug - the values ending with .2 .4 and .7 .8 get values like
1.2000000000000002, etc...

#high comfort for climate control

comfortctrl_high:
  name: Comfort High
  initial: 1.5
  min: 1.1
  max: 1.8
  step: 0.1

the Low slider behaves correctly.

#Low comfort for climate control
comfortctrl_low:
  name: Comfort Low
  initial: 0.9
  min: 0
  max: 1
  step: 0.1

@alexciurea
Copy link

sorry - by mistake i missed to see this is angular and not [directly] relevant to home assistant/hassio issue tracker.

for now, please ignore my reporting that this is still an issue.
I'm not even sure what angular version used by home assistant (and in fact, not even certain the 2 issues / projects are related - although the behavior is clearly similar).
thanks
-a

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants