You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[preact/compat] radix-ui Slider component drag points (Thumbs) not working #3666
Load the stackblitz example above and drag the edges of the white lines:
While the line itself is adjustable, the Thumb components are not shown. If the nested span's css is modified from display: none to display: block the Thumb element is rendered on left edge with 0, 0 coords.
Expected behavior
For slider thumbs to be attached to end of white line and to move along with them.
Additional context
Slider component used to hang the app as did the Dialog in this bug report #3297. Since version 10.10.1 and this #3645 fix specifically the Slider component now no longer hangs the app but it's not 100% working either with Thumb component being broken.
Took a stab at this too. From what I can tell so far is that this is caused by a combination of re-renders and abusing refs as state updaters. So what the radix-ui team is doing akin to this:
functionFoo(){const[thumb,setThumb=useState(null);// Ref is abused as a state setter.return<buttonref={(el)=>setThumb(el)}/>}
In the real code base there are a few abstractions in-between like the composedRefs thing, but that's essentially the pattern they are doing. But why does that lead to a different rendering result in Preact vs React?
That can be answered by looking into how both frameworks deal with state updates during a commit is being batched. In Preact we just re-queue the component and once the queue is components is flushed (meaning all components finished rendering), then we fire all pending effects that that were scheduled via useEffect.
Problem is that during the rendering of the re-queued component which holds the thumb state, the state holds now the DOM reference. But that reference is the only thing guarding the invocation of getItems, which is ultimately responsible for setting the thumb index, which ends up controlling what kind of value (=slider position) the thumb has. But because the index is -1 the value is undefined and when the value is undefined the thumb controller adds a display: none to the thumb.
The whole logic relies on this useEffect being called, by which point getItems returns a valid index and the thumb is shown.
In React this works, because the effects seem to be executed before a re-queued element is rendered, instead of at the end when all components have been rendered.
This still seems to be an ongoing issue with the radix slider when using preact.
As you can see in the attached image the user has dragged the left thumb to $15 and the right thumb to $55. However, the left thumb hasnt moved and the right thumb was not even visible to begin with.
Activity
JoviDeCroock commentedon Aug 12, 2022
So far I have been able to narrow it down to this useCollection, this
getItemsis not returning the thumbsmarvinhagemeister commentedon Aug 14, 2022
Took a stab at this too. From what I can tell so far is that this is caused by a combination of re-renders and abusing
refsas state updaters. So what the radix-ui team is doing akin to this:In the real code base there are a few abstractions in-between like the
composedRefsthing, but that's essentially the pattern they are doing. But why does that lead to a different rendering result in Preact vs React?That can be answered by looking into how both frameworks deal with state updates during a commit is being batched. In Preact we just re-queue the component and once the queue is components is flushed (meaning all components finished rendering), then we fire all pending effects that that were scheduled via
useEffect.Problem is that during the rendering of the re-queued component which holds the
thumbstate, the state holds now the DOM reference. But that reference is the only thing guarding the invocation ofgetItems, which is ultimately responsible for setting the thumbindex, which ends up controlling what kind of value (=slider position) the thumb has. But because the index is-1the value isundefinedand when the value isundefinedthe thumb controller adds adisplay: noneto the thumb.The whole logic relies on this
useEffectbeing called, by which pointgetItemsreturns a validindexand the thumb is shown.In React this works, because the effects seem to be executed before a re-queued element is rendered, instead of at the end when all components have been rendered.
Change:Slider を 一部 利用可能に
arpu commentedon Jun 5, 2025
is there any workaround we can do?
TJGinis commentedon Feb 10, 2026
This still seems to be an ongoing issue with the radix slider when using preact.
As you can see in the attached image the user has dragged the left thumb to $15 and the right thumb to $55. However, the left thumb hasnt moved and the right thumb was not even visible to begin with.