Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent slider thumb position with controlled slider state #3270

Open
3 tasks done
JAD3N opened this issue Jan 27, 2025 · 1 comment
Open
3 tasks done

Inconsistent slider thumb position with controlled slider state #3270

JAD3N opened this issue Jan 27, 2025 · 1 comment

Comments

@JAD3N
Copy link

JAD3N commented Jan 27, 2025

Description

When using a controlled slider if the slider value does not change when using the onValueChange callback the thumb will not revert back to the position of it's set value.

For example if the value is set to 0, and you drag the slider to 50 but the onValueChange callback decides that the value should not have changed the slider will stay at 50 instead of reverting back to 0.

Link to Reproduction

https://stackblitz.com/edit/chakra-ui-v3-jm7hd4ud?file=src%2FApp.tsx

Steps to reproduce

  1. Go to reproduction.
  2. If you drag the slider to positions and let go it will have an 80% chance of being ignored (for test purposes), do this multiple times if necessary until the value doesn't match the position of the slider.
  3. Notice the value being shown will not match the value for the slider (only if the change callback doesn't trigger any updates).
  4. When the value doesn't match you can then press the update button which will force an update which will fix the slider.

Chakra UI Version

3

Browser

Chromium 131

Operating System

  • macOS
  • Windows
  • Linux

Additional Information

For me the only workaround was either to forcibly update the state after the callback or to use useSlider and replicate the slider snippet.

@segunadebayo segunadebayo transferred this issue from chakra-ui/chakra-ui Jan 30, 2025
@segunadebayo
Copy link
Member

Transferred to ark, where it'll be fixed.

For now, we recommend setting the state in the onValueChange callback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants