Skip to content

fix: allow single-digit values in NumberField input (#58)#60

Merged
AmethystLiang merged 1 commit intomainfrom
AmethystLiang/changeDividerThickness
Mar 23, 2026
Merged

fix: allow single-digit values in NumberField input (#58)#60
AmethystLiang merged 1 commit intomainfrom
AmethystLiang/changeDividerThickness

Conversation

@AmethystLiang
Copy link
Copy Markdown
Contributor

Problem

When typing a single-digit value (e.g. "5") in the divider thickness or opacity fields, the input would jump to a double-digit value with "1" stuck at the front (e.g. "15"). This made it impossible to set single-digit values.

The root cause: NumberField was calling onChange on every keystroke, which triggered immediate validation and clamping. When clearing the field to type a new value, the empty field would be clamped to the minimum (1), and the "1" would get stuck.

Solution

Changed NumberField to use a draft/commit pattern:

  • Input maintains local state as the user types (no immediate validation)
  • Value is only validated and committed on blur or Enter keypress
  • Empty input resets to the current value instead of committing 0
  • This allows smooth, single-digit value entry while still maintaining min/max constraints

Fixes #58

NumberField was calling onChange on every keystroke, which triggered
clampNumber immediately. Clearing the field to type a single digit
caused the value to snap back to min (1), making it impossible to
enter single-digit values like "5" (it would become "15").

Switch to a draft/commit pattern: maintain local state while typing,
only validate and commit clamped values on blur or Enter. Empty input
resets to the current value instead of committing 0.

Closes #58

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@AmethystLiang AmethystLiang merged commit b6b1a27 into main Mar 23, 2026
@AmethystLiang AmethystLiang deleted the AmethystLiang/changeDividerThickness branch March 23, 2026 23:17
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.

Can't change divider thickness to single digit values. It always goes to double digit value with "1" stuck there

1 participant