Skip to content

A Parameter's Value, Min, Max and Step say when what you type is not a number - #665

Merged
MerciHanrim merged 1 commit into
mainfrom
parameter-finite-number-hint
Nov 24, 2026
Merged

MerciHanrim merged 1 commit into
mainfrom
parameter-finite-number-hint

Conversation

@MerciHanrim

Copy link
Copy Markdown
Owner

Part of #615 (follow-up: Min / Max / Step hints; Value included by Lumi's scope).

What was wrong

Measured on main 5855c9ee:

  • A Parameter's Value, Min, Max and Step marked a draft that is not a finite number (a half-typed - or 1e, an overflow such as 1e400) with aria-invalid only; no hint text. A Pool's Capacity shows its own hint ("Enter a number that is 0 or greater.") for the same drafts.
  • - typed into an empty Min, Max or Step was not marked at all. The browser does send the native input event, with validity.badInput true, but the input reports '' before and after, so React's onChange (which fires only when the value changes) never ran. The Backspace that removes the - again also comes only as an input event.
  • Nothing invalid was stored; after leaving, each field showed its stored value.

The change

  • DraftNumberInput also listens to onInput, and handles it only while the field shows '' (whenever it shows anything else, onChange runs for the same event). There it records the half-typed state from validity.badInput, so the field is marked; a following Backspace makes it a real blank again. A blank that would only set what is already stored commits nothing.
  • The Parameter's Value, Min, Max and Step use a small FiniteNumberField that shows the new hint "Enter a finite number." inside the field while the draft is not a number, as NonNegativeNumberField does for a Pool.
  • The existing rules stay: a blank Min, Max or Step is allowed (it removes that advisory value); a blank Value is not. The coherence notes (min ≤ max, step > 0) are unchanged.
  • New catalog key inspector.number.finiteHint in all 18 locales. The key-count pins move from 1542 to 1543 (runtime 1817 to 1818) in the it, nl, pt-PT, ru, th, tr and vi copy tests.
  • docs/specs/SEMANTICS-M.md §M1.2 states the editing rule.

Tests

New describe in e2e/number-field-blank.spec.ts:

  1. Value, Min, Max, Step (one test each): - shows the hint and aria-invalid, then 3 (-3) clears it and is stored; 1e shows it, leaving clears it; 1e400 shows it, Backspace to 1e40 clears it; - then Backspace: a blank clears it for Min, Max and Step (stored blank) and keeps it for Value (stored value kept, cleared on leaving). Nothing invalid is stored at any point.
  2. Min, Max, Step: - typed into the empty field is marked with the hint; leaving clears it and the field stays blank.
  3. Control: Pool capacity keeps its own hint for - and -3, stores nothing for them, and a blank still means unlimited.

On main's code, tests 1 fail at the first hint check and tests 2 at the first aria-invalid check; the control passes.

Updated: the #615 item 2 test in the same file now expects the new hint for Min, Max and Step; e2e/parameter-inputs.spec.ts finds the Value field by role and a name that may carry the hint (the hint is inside the label, so it joins the field's accessible name while it shows, as Capacity's does).

On this branch, --workers=1 --retries=0:

  • e2e/number-field-blank.spec.ts (chromium): 20 passed.
  • e2e/node-value-overflow.mobile.spec.ts (mobile): 2 passed.
  • parameter-inputs, field-undo, monte-carlo, step-length-field, rtl-form-direction, mc-invalidation, inspector-kind-label, node-value-overflow (chromium): all passed.

Every check:* script, tsc -b, lint (88 warnings, the baseline, none in the changed components) and vitest run (5758 passed) pass.

…a number

These four Inspector fields marked a draft that is not a finite number (a half-typed `-` or `1e`, an overflow such as `1e400`) with aria-invalid only, and a `-` typed into an empty Min, Max or Step was not marked at all: the number input reports '' before and after, so React's onChange never ran. DraftNumberInput now also handles the native input event while the field shows '' (validity.badInput tells a half-typed number from a blank), and the four fields show the new hint "Enter a finite number." (inspector.number.finiteHint, 18 locales) while the draft is not a number, as a Pool's capacity shows its own. A blank Min, Max or Step is still allowed and a blank Value is not; nothing invalid is stored.

Part of #615
@MerciHanrim MerciHanrim added the bug Something isn't working label Nov 24, 2026
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying cozy-loop-studio with  Cloudflare Pages  Cloudflare Pages

Latest commit: d2470a8
Status: ✅  Deploy successful!
Preview URL: https://a5a00aa1.cozy-loop-studio.pages.dev
Branch Preview URL: https://parameter-finite-number-hint.cozy-loop-studio.pages.dev

View logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant