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

refactor: slightly more accessible and consistent number input #415

Merged
merged 1 commit into from
Feb 12, 2025

Conversation

Charlie-XIAO
Copy link
Contributor

Radix UI does not have a number field component, which is pretty sad. Relying on some external component library (or even their hook) would probably be too heavy and overkill. This PR just added some accessibility to the <input type="number"> thing (note: it did not change to type="text" and inputMode="numeric", because though type="number" is a little bit inconsistent in validation, its default snappers can reduce a lot of our work, so at least I kept it for now).

New behaviors:

  • Home/End: Go to min/max.
  • Shift+UpArrow/DownArrow: Increment/decrement by 10x multiplier.

Other behaviors are the same as before, but again hardcoded instead of using the default behavior which could be inconsistent across browsers. This also has better validation (to tackle inconsistency problems) and better clamp & snap behavior.

@Charlie-XIAO Charlie-XIAO merged commit f21c874 into main Feb 12, 2025
11 checks passed
@Charlie-XIAO Charlie-XIAO deleted the refactor/integer-input branch February 12, 2025 15:50
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

Successfully merging this pull request may close these issues.

1 participant