fix(studio): clamp NumberField commits to their bounds by shuaiyafei · Pull Request #5947 · heygen-com/hyperframes · GitHub
Skip to content

fix(studio): clamp NumberField commits to their bounds - #5947

Open
shuaiyafei wants to merge 1 commit into
heygen-com:mainfrom
shuaiyafei:codex/number-field-enter-bounds
Open

shuaiyafei wants to merge 1 commit into
heygen-com:mainfrom
shuaiyafei:codex/number-field-enter-bounds

Conversation

@shuaiyafei

@shuaiyafei shuaiyafei commented Oct 20, 2026 •

Copy link
Copy Markdown

What

Clamp the exported @hyperframes/studio/ui NumberField's committed value to its min and max.

Why

With value={24}, min={0} and max={100}, typing 150 and pressing Enter sends 150 to onCommit. With a minimum of 10, typing 5, pressing Enter and then leaving the field produces two commits: [5, 10].

These out-of-range commits can propagate invalid values and cause a second write at blur. Both cases reproduce through the public UI export with real Chrome keyboard input.

Related work

This is a self-contained correction. Open and historical NumberField PRs were checked before implementation. PR #4710 changes Select and shares the test file; the added cases here belong to the NumberField suite.

How

Apply the bounds before comparing with the last committed value and notifying the caller. Synchronize the bounded numeric draft so the following blur deduplicates correctly.

Base UI owns the focused editing text and formats it on blur. The captures below are taken immediately after Enter: the lower panel shows the value received by the caller.

Test plan

Local verification: macOS arm64, Bun 1.4.3 and Node 24.19.0.

GitHub Actions are awaiting maintainer approval for this fork PR. Remote tests have not executed.

  • All six new regression cases fail against the original NumberField source.

  • All 69 tests under src/components/ui pass, including upper/lower bounds, one-sided bounds, a zero maximum, and a no-op at an existing bound.

  • Five real Chrome Headless Shell 152.0.7977.30 scenarios exercise keyboard input through the public UI export. They verify committed values, retained focus, and the following blur without duplicate commits.

  • Full workspace build and lint pass.

  • Complete pre-commit and commit-msg hooks pass, including typechecks, Fallow, lint, formatting, tracked-artifact and large-file checks.

  • Comment citations and the comment ratchet pass.

  • The commit is marked Verified by GitHub.

  • Unit tests added/updated

  • Manual testing performed — browser verification was automated, with before/after captures

  • Documentation updated (if applicable)

  • Comments follow CONTRIBUTING.md "Comments": they say why, not what, and a bug fix says what the code must do and how to reproduce the bug

Before

Input 150, declared maximum 100, caller receives 150.

Before: the caller receives an out-of-range value

After

The same input and Enter key, caller receives 100.

After: the caller receives the bounded value

AI-assisted implementation with Codex. The validation listed above was executed.

Bound the numeric value before deduplicating and notifying the caller.
Keep the bounded draft synchronized so the subsequent blur does not
commit another value or emit a duplicate tracking event.

Cover both bounds, one-sided bounds, a zero maximum, and a no-op at the
already committed bound.

This branch has not been deployed

No deployments
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