Commit 18d43a3
fix: enable decimal input in Number field
The Number component was rejecting decimal input due to two issues:
1. No `formatOptions` passed to react-aria's `useNumberFieldState` and
`useNumberField`, so the NumberParser rejected decimal characters
during input validation.
2. The `<input>` value was overridden with `Number.isInteger(state.numberValue)
? state.numberValue : 0`, which collapsed any non-integer to 0 — preventing
the user from ever typing a decimal point.
Fix: pass memoized `formatOptions` with `maximumFractionDigits: 10` to both
hooks (must be memoized — react-stately uses reference equality), remove the
value override so react-aria controls the input natively, and expose a `step`
prop (default 1) for +/- button increment granularity.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 78106ab commit 18d43a3
File tree
3 files changed
+26
-22
lines changed- assets
- build
- src/components/field/number
3 files changed
+26
-22
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
26 | 30 | | |
27 | 31 | | |
28 | 32 | | |
| |||
32 | 36 | | |
33 | 37 | | |
34 | 38 | | |
35 | | - | |
| 39 | + | |
36 | 40 | | |
37 | 41 | | |
38 | 42 | | |
| |||
53 | 57 | | |
54 | 58 | | |
55 | 59 | | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
60 | 64 | | |
61 | 65 | | |
62 | 66 | | |
| |||
0 commit comments