palantir / blueprint

A React-based UI toolkit for the web
https://blueprintjs.com/
Apache License 2.0
20.51k stars 2.15k forks source link

Slider fill with negative min, positive max, initialValue of 0 has the wrong track fill at zero #6844

Closed rmatan closed 1 week ago

rmatan commented 3 weeks ago

Steps to reproduce

  1. configure a Slider with a negative min and positive max (or, any case where min < initialValue && max > initialValue && value === initialValue)
  2. move the Slider handle to zero (or if not using the default initialValue, then move the Slider handle to initialValue)

Actual behavior

The track fills from min to zero (or initialValue) with the primary intent.

Expected behavior

No track fill, since it's only supposed to be between initialValue and value.

Possible solution

the issue is that here when the slider's value equals the initialValue, the first slider handle created has an intentBefore defined. Then the track fill is created from three segments: min to first slider handle [-100% to 0%] first slider handle to initial value [0% to 0%] initial value to max [0% to 100%] Since the first segment's endpoint has an intentBefore , it gets filled in, in this case with the primary intent

It seems like it should only set an intentBefore if value > initialValue and not if value === initialValue.