Slider Range update causes the slider to break #1512
-
I'm trying to use the Slider primitive to operate a price filter for Algolia. Because the slider is one of the many facets exposed by Algolia, the range the slider can operate within can change as the user interacts with other facets. Is there a way to reset the primitive when that happens? Currently when this happens and I try to change the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey @lmartins, Are you controlling the Slider with In any case, if the range dynamically changes, you will need to make sure the current value it holds is within the current valid range as we only validate this when interacting with the component (pointer/keyboard), but not when you are setting the value ( It's a bit difficult without seeing an example, but I believe that's the issue and you just need to clamp the current value within the range when it changes. If you are NOT controlling the component, to be able to update Let me know how you get on! ✌️ |
Beta Was this translation helpful? Give feedback.
Hey @lmartins,
Are you controlling the Slider with
value
/onValueChange
, or using in an uncontrolled way withdefaultValue
?In any case, if the range dynamically changes, you will need to make sure the current value it holds is within the current valid range as we only validate this when interacting with the component (pointer/keyboard), but not when you are setting the value (
defaultValue
orvalue
).It's a bit difficult without seeing an example, but I believe that's the issue and you just need to clamp the current value within the range when it changes.
If you are NOT controlling the component, to be able to update
defaultValue
and have it update the component, you will need to use React's