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

[Feature] (NumberField): Add Option to Disable snapValueToStep #1593

Open
2 tasks
rooom-nikita opened this issue Jan 30, 2025 · 2 comments
Open
2 tasks

[Feature] (NumberField): Add Option to Disable snapValueToStep #1593

rooom-nikita opened this issue Jan 30, 2025 · 2 comments

Comments

@rooom-nikita
Copy link

Describe the feature

Currently, snapValueToStep is ignored only when no step is provided, which is unlikely in most cases. Since the default step value is 1, this behavior can lead to unexpected rounding, especially when format options like minimumFractionDigits and maximumFractionDigits are specified. This can result in inconsistent number formatting

Proposed Solutions
To improve flexibility, I propose one of the following:

  1. Add a Prop – Introduce an additional prop to control whether values should snap to the step value.
  2. Disable Snapping When Formatting is Applied – Automatically disable snapValueToStep if minimumFractionDigits or maximumFractionDigits are specified, ensuring the input value maintains its intended precision.

Code Reference
https://github.com/unovue/radix-vue/blob/33f50be4fd6cb2370fb44b714a3fcde0e020b819/packages/core/src/NumberField/NumberFieldRoot.vue#L147-L157

Would love to hear thoughts on this approach

Additionally, I found a potentially related discussion here: #977

Additional information

  • I intend to submit a PR for this feature.
  • I have already implemented and/or tested this feature.
@rooom-nikita
Copy link
Author

And maybe this #1523

@emilsgulbis
Copy link

Almost lost my mind before found this.
1st option with snap props feels the best, "auto snapping" feels really unexpected

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