seiyria / bootstrap-slider

A slider control for Bootstrap 3 & 4.
http://seiyria.github.io/bootstrap-slider/
Other
3k stars 1.14k forks source link

Range slider, min value over max value. #854

Closed Alhubing closed 5 years ago

Alhubing commented 5 years ago

Hello, i've noticed that if you create a range slider, step value set at 1, you can drag the min handle over the max handle for 1 step.

There you have the example.

http://jsfiddle.net/95chpj1d/13/

Yo have to drag the min handle, and when the min value gets to the max value, it can go 1 unit over the max.

You can check it in the console. At some point you can get an output like [0, 1] -> [1, 1] -> [2 ,1]

You can get the same behaviour if you drag the max handle over the min handle.

Thanks.

seiyria commented 5 years ago

It was implemented this way intentionally, if I remember correctly it will switch the handles around when it makes sense to do so.

Alhubing commented 5 years ago

The handles don't change until there is a difference of more than one unit.

[1,0] -> [0,0] => [1,0] => [0,2]

The correct behaviour would be

[1,0] -> [0,0] => [0,1] => [0,2]

If you give different colours to each handle you can see how the min handle goes over the max handle and they don't switch.

Thanks.

Alhubing commented 5 years ago

Please, could you give a hint about this? Thank you.

jespirit commented 5 years ago

I was able to reproduce the bug. Check this JSFiddle https://jsfiddle.net/9L65wxa3/

Range starts at [5, 7]

To reproduce:

  1. Using the mouse, drag the the lower handle past the upper handle so the values are [7, 8]
  2. Tab control to the upper handle and press Left arrow twice.
  3. Result is [7, 8] => [7, 7] => [7, 6]

I have a fix which is a single line of code. I just need to add unit test for it.