Sharcoux / slider

React-Native and React-Native-Web compatible slider
ISC License
156 stars 31 forks source link

Slider Value gets "stuck" when rapidly tapping to move position #100

Open spiralman opened 3 days ago

spiralman commented 3 days ago

Describe the bug If you rapidly tap/click on the slider to move the position, the slider will eventually get "stuck" at a fixed position. All calls to the onSlidingStart and onSlidingComplete callbacks will receive the "stuck" value (which is whatever the value prop is set to), but calls to onValueChange will receive the actual value represented by the position the user tapped/clicked.

This is easily reproduced with your demo app, without changes. We've also reproduced this in Android and iOS apps (not using Expo).

To Reproduce

Expected behavior The thumb should not get "stuck", the callback to onSlidingStart and onSlidingComplete should get a value representative of the position the user tapped/clicked/dragged the thumb, not whatever the current value prop is set to.

Screenshots See this example console output, from after the bug has been triggered: image

Please complete the following information:

Additional context Note: it appears to be possible to work around this issue by updating the parent component's value state in the onValueChange callback, which causes the correct value to be passed back down into the slider, thus resulting in the onSlidingStart/Complete callbacks getting the updated value.

Sharcoux commented 3 days ago

Interesting. I could reproduce, but I really had to go crazy on the slider. I'll try to check what's going on. The issue is that I had to borrow a mouse to reproduce the issue and I don't have one for now :sweat_smile:

spiralman commented 3 days ago

Thanks @Sharcoux. FWIW, I've found an easy way to reproduce it on a phone is, if the slider goes full-width on the device, you can use your two thumbs to tap back and forth between the left and right sides of the slider more rapidly than with a single finger (although, I can definitely get it to happen with just a single finger).

Sharcoux commented 3 days ago

Did you try with the latest version? The snack uses an older version.

spiralman commented 3 days ago

@Sharcoux We can reproduce the bug using 7.2.1, which is the current latest version.