primitives: [Slider] onValueCommit not being called properly
Bug report
Sometimes the onValueCommit prop is not being called properly when moving the thumb.
Current Behavior
When moving the thumb sometimes the onValueCommit prop is not called.
Expected behavior
To always call the onValueCommit prop when the user stops sliding
Reproducible example
I’m using the same example from the documentation.
Your environment
| Software | Name(s) | Version | 
|---|---|---|
| Radix Package(s) | slider | 1.1.0 | 
| React | n/a | 18.2 | 
| Browser | chrome | 107.0.5304.87 (Official Build) (arm64) | 
| Assistive tech | ||
| Node | n/a | |
| npm/yarn | ||
| Operating System | macOS | Version 13.0 | 
About this issue
- Original URL
 - State: open
 - Created 2 years ago
 - Reactions: 20
 - Comments: 41 (2 by maintainers)
 
I’m on an M1, latest OSX & Chrome, so the only diff would be trackpad?
I just tried on the trackpad rather than using my mouse and I can reproduce it! That’s very strange that trackpad vs. mouse would make a difference…
At least now I know how to reproduce it now, so I can look into it 🙂
Thanks!
Adding a “onLostPointerCapture” handler seems to fix the issue.
Bumping this… This is a pretty obvious bug and renders this essential component useless in most applications due to the inconsistency.
I seem to have solved this too by adding a
onLostPointerCapturehander to commit the value but it sure is alarming that this issue continues to persist.Hey everyone, we are also having this issue with
onValueCommitnot being called properly. In our case, we are using two thumbs and aminStepsBetweenThumbsof 0. TheonValueCommitfunction is not called when the right thumb gets dragged all the way to the left. It works the other way around though. This is easily reproducible and a reproduction is available here in this sandbox.Ok, well that shows it has nothing to do with the iframe, thanks. However, I’m still struggling to reproduce it or understand how you are doing it 😀
One thing to note is that
onValueCommitwill only trigger is the value has actually changed, but from what I can see (although tricky with just watching a video) it looks like you are changing it.Could you try logging the value you receive in
onValueCommitand also logging the value inonValueChangeand reproduce?Upon further investigation, I discovered that the
onPointerUpevent fails to trigger when rapidly moving the slider outside of the document. Consequently, theonValueCommitprops is not invoked since they rely on theonPointerUpevent.My temporary workaround made:
Hope it helps! @benoitgrelard @vctormb