airbnb / rheostat

Rheostat is a www, mobile, and accessible slider component built with React
MIT License
1.69k stars 189 forks source link

`min` prop is opposite of what is expected #296

Open Yamikaze123 opened 3 weeks ago

Yamikaze123 commented 3 weeks ago

I don't see much documentation on min prop in the README, so please correct me if I am understanding this wrongly, but passing value to min prop is having the opposite effect as it should. Passing a positive value is causing the thumb to move left

ljharb commented 3 weeks ago

I'm not sure what you're asking; min is the minimum value. It's not meant to be changed.

I do see the odd behavior when the value is already set to something below the new minimum value, and that should be fixed here by clamping the current value so it's not less than the min.

Yamikaze123 commented 3 weeks ago

It is a visual discrepancy. As you mentioned, min is the minimum value but passing a positive value to min is moving the slider left, meaning user can see that 0 is still a valid value, which it should not. If we move the slider right, it shows that we can only have values more than min

ljharb commented 3 weeks ago

It's not about that - it's that you default the values to [0], and you're responsible for ensuring that none of the values are greater than the min.

If you change the default to Math.min(0, m) where m is the min value, it'll work fine.

Yamikaze123 commented 3 weeks ago

That makes sense, setting the default to Math.max(0, min) does the trick