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

[Slider] Warn when min is not less than max #1475

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mj12albert
Copy link
Member

Fixes #1471

Log a console warning when min is not less than max and don't update the state. When min/max are the same something divides by zero internally and causes a loop.

@mj12albert mj12albert added component: slider This is the name of the generic UI component, not the React module! bug 🐛 Something doesn't work labels Feb 24, 2025
Copy link

netlify bot commented Feb 24, 2025

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 7da0a5b
🔍 Latest deploy log https://app.netlify.com/sites/base-ui/deploys/67bca98d9e62be0008bc77ea
😎 Deploy Preview https://deploy-preview-1475--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@mj12albert mj12albert changed the title [Slider] Handle min not less than max [Slider] Warn when min is not less than max Feb 25, 2025
@mj12albert mj12albert marked this pull request as ready for review February 25, 2025 06:27
@mj12albert
Copy link
Member Author

https://codesandbox.io/p/sandbox/slider-bug-min-and-max-the-same-forked-kz8xgy

It doesn't crash and logs a warning, I think this should be enough

@michaldudak
Copy link
Member

I can imagine a case where the min/max values are set based on some state set in other parts of the application (i.e., not hardcoded), and with certain conditions, the Slider could allow just a single value. IMO we should support such a scenario.

@mj12albert
Copy link
Member Author

with certain conditions, the Slider could allow just a single value

All we could do differently though is not warn if min/max are the same? If min/max/value are all the same, it's still not possible to determine a position on the track @michaldudak

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: slider This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Slider] Maximum depth exceeded bug when min and max is 1
2 participants