-
Notifications
You must be signed in to change notification settings - Fork 77
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: round handle labels and event values? #557
Comments
Yeah, a prop for number of decimals you'd like to report or something (default to 2) would maybe be a route to go. Or some sort of formatter function that the dev can define which accepts the value and returns a string, maybe? |
I'm happy to give this a go and provide a PR with a little guidance from previous contributors to this component. Not sure if the correct spot would be within As another default idea, what if it attempts to round based on the If I want Although looking at this now that I typed it out, there could be a bunch of edge cases I'm not considering. Perhaps then as a first draft, your idea @paulcpederson, for a number of decimals optional prop is a solid way to go. Again, happy to work on this if I can get some pointers on which method would be the best to jam this into as an optional return value formatter. |
Yeah, I think there are more use cases too, like a tile range slider. It goes from 1-12 but really the user would want to see that reported as "world", "streets", "state". Ie. the human readable label for that scale level. Having the default behavior you've outlined above I thin would be a good step until we figure out a more robust customization strategy. We may want to use a localized number formatter as decimals are different in different locales ( |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically closed due to inactivity. |
Consider a
<calcite-slider>
with these params:It is possible to easily get to this kind of state with JS floating point issues:
Could there be an option to attempt to "round" the
value
internally (andminValue
andmaxValue
when using a range slider) before communicating it outside of this component?I'm attempting to work around this in the
calciteSliderUpdate
event with something like this snippet (but it doesn't fix the rendered labeled handle until later):The text was updated successfully, but these errors were encountered: