fix: allow single-digit values in NumberField input (#58)#60
Merged
AmethystLiang merged 1 commit intomainfrom Mar 23, 2026
Merged
fix: allow single-digit values in NumberField input (#58)#60AmethystLiang merged 1 commit intomainfrom
AmethystLiang merged 1 commit intomainfrom
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
onChangeon 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:
Fixes #58