fix(number-range): draft inputs, NaN guards, validation (#857) - #864
Conversation
The number-range slider added in #853 had several rough edges in the input + value pipeline that surfaced once the dual-thumb primitive landed. Fixes: - NumberRangeSlider min/max inputs now track a draft string and commit on blur/Enter. Previously `Number("-")` was NaN and silently no-op'd, leaving the field dead while typing a negative. - handleSliderChange falls back to a sane second value when Radix emits a single-element array (min===max edge case), so the tuple is always [number, number]. - param-number-range.tsx now drops non-finite tuples from the restore path instead of producing [NaN, NaN] slider state. - form-fields-editor number-range section refactored into its own component with draft state. Empty clear no longer silently zeros rangeMin via `Number("") === 0`. step <= 0 keeps the prior value. - Inline validation error when min >= max or step <= 0. Tests: - New draft-and-blur behavior coverage on the slider + editor. - NaN-guard coverage on the restore path. - Min/max validation message coverage.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (3)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
NumberRangeSlider now uses text inputs (inputMode=numeric) with
commit-on-blur, so:
- accessible role is `textbox`, not `spinbutton` — target inputs by
their aria-label (`<param> minimum` / `<param> maximum`)
- `fill()` only updates the draft; commit requires blur — add an
explicit `press("Tab")` after each fill so the parameter store
actually updates
Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
Brings Sonar new-code coverage for number-range-slider.tsx above the 80% gate. Targets previously uncovered branches: - float numberType (preserves decimals; no Math.round) - integer numberType (rounds 3.7 → 4) - NaN draft revert on blur for both min and max inputs - Enter key commits on the max input (already covered for min) - draft inputs resync when the value prop changes externally (e.g. slider drag while inputs are unfocused) - showInputs defaults to true when prop is omitted Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
|



Closes #857. Stacks on top of #853.
Summary
Polishes the number-range slider primitive + value pipeline added in #853:
renders one Thumb per value-array element — verified, no change.
string that commits on blur/Enter. Fixes the regression where typing
the leading minus of a negative number left the input dead (because
Number(\"-\")is NaN and the old handler silently no-op'd).handleSliderChangefalls back when Radixemits a single-element array (min===max), so we always emit
[number, number].NaN-guard the tuple — a corrupt restore previously left the slider
stuck at
[NaN, NaN].component with draft state. Empty clear no longer silently zeros
rangeMinviaNumber(\"\") === 0. Step ≤ 0 keeps the prior value.Inline validation error when
min >= maxorstep <= 0.Why stacked on #853
PR #853 introduces the number-range type; this PR fixes bugs in that
type, so the diff has to be applied on top of #853's branch.
Test plan
parameter-widgets.test.tsx(90 pass, including 5 new draft/blur/Enter cases)param-number-range.test.ts+form-fields-editor.test.tsx(34 pass, including new validation + restore tests)🤖 Generated with Claude Code