Skip to content

Fix number input eager clamping on keystrokes#583

Merged
Flaminel merged 2 commits into
Cleanuparr:mainfrom
MikeTheCanuck:fix/number-input-clamping
Apr 25, 2026
Merged

Fix number input eager clamping on keystrokes#583
Flaminel merged 2 commits into
Cleanuparr:mainfrom
MikeTheCanuck:fix/number-input-clamping

Conversation

@MikeTheCanuck

Copy link
Copy Markdown
Contributor

Description

Fixes eager min/max clamping in the app-number-input component that interrupted typing mid-keystroke. Previously, onInput called Math.max/Math.min on every keystroke, so typing -1 would clamp to 0 after the -, and typing 1000 would clamp to the max after each digit.

The fix moves clamping to onBlur: the value is clamped and the DOM input synced only when the field loses focus, leaving the user free to type any intermediate value.

Related Issue

Closes #581

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Testing

  • Typed -1 into Max Ratio, Max Seed Time, and Max Inactive Days fields — no mid-keystroke jumps
  • Typed 1000 into a field with [max]="999" — value clamped correctly on blur
  • Typed and then cleared a field — no errors, value resets to null as before

Checklist

Move min/max clamping from onInput to onBlur so users can type
intermediate values (e.g. "-1", "100") without the field jumping
mid-keystroke. The blur handler clamps and syncs the DOM value if
needed, then delegates to the existing blurred emitter.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread code/frontend/src/app/ui/number-input/number-input.component.ts Outdated
Comment thread code/frontend/src/app/ui/number-input/number-input.component.ts Outdated
- Add braces to single-line if statements in onBlur (style consistency)
- Remove manual DOM value sync; signal update triggers change detection
  and syncs the input display without it

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Flaminel Flaminel merged commit db2e3e7 into Cleanuparr:main Apr 25, 2026
1 check passed
@Flaminel

Copy link
Copy Markdown
Contributor

Thank you very much for your contribution!

@MikeTheCanuck MikeTheCanuck deleted the fix/number-input-clamping branch April 26, 2026 05:59
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.

[BUG] Number input clamps value on every keystroke, making it painful to type large values

2 participants