Skip to content

fix(number-range): draft inputs, NaN guards, validation (#857) - #864

Merged
alfredo1996 merged 3 commits into
feat/v1-number-range-and-demosfrom
fix/857-number-range-slider
May 19, 2026
Merged

fix(number-range): draft inputs, NaN guards, validation (#857)#864
alfredo1996 merged 3 commits into
feat/v1-number-range-and-demosfrom
fix/857-number-range-slider

Conversation

@alfredo1996

Copy link
Copy Markdown
Owner

Closes #857. Stacks on top of #853.

Summary

Polishes the number-range slider primitive + value pipeline added in #853:

  • Slider primitive (component/src/components/ui/slider.tsx): already
    renders one Thumb per value-array element — verified, no change.
  • NumberRangeSlider (component): min/max inputs now use a draft
    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).
  • Slider tuple guarantee: handleSliderChange falls back when Radix
    emits a single-element array (min===max), so we always emit
    [number, number].
  • Restore path (app/src/components/parameters/param-number-range.tsx):
    NaN-guard the tuple — a corrupt restore previously left the slider
    stuck at [NaN, NaN].
  • form-fields-editor: extracted number-range editor 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.

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

  • Component unit tests — parameter-widgets.test.tsx (90 pass, including 5 new draft/blur/Enter cases)
  • App unit tests — param-number-range.test.ts + form-fields-editor.test.tsx (34 pass, including new validation + restore tests)
  • CI: typecheck, full unit & integration, E2E, SonarCloud

🤖 Generated with Claude Code

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.
@coderabbitai

coderabbitai Bot commented May 19, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (3)
  • main
  • dev
  • release/.*

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e3486f11-10e5-48b5-9658-972e8200637c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/857-number-range-slider

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

alfredorubin96 and others added 2 commits May 19, 2026 02:48
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>
@sonarqubecloud

Copy link
Copy Markdown

@alfredo1996
alfredo1996 merged commit 4578dcc into feat/v1-number-range-and-demos May 19, 2026
13 checks passed
@alfredo1996
alfredo1996 deleted the fix/857-number-range-slider branch July 3, 2026 12:42
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.

2 participants