Skip to content

Fix numeric digit landing in decimal area when typed before prefix (#2615)#2881

Open
thorn0 wants to merge 1 commit intoRobinHerbots:5.xfrom
thorn0:fix/numeric-cursor-before-prefix-2615
Open

Fix numeric digit landing in decimal area when typed before prefix (#2615)#2881
thorn0 wants to merge 1 commit intoRobinHerbots:5.xfrom
thorn0:fix/numeric-cursor-before-prefix-2615

Conversation

@thorn0
Copy link
Copy Markdown
Contributor

@thorn0 thorn0 commented Apr 10, 2026

Summary

When the cursor is placed before the prefix on a numeric mask with radixPoint, the DOM position translates past the buffer end, causing _isValid to fall through to alternation switching and place the digit in the decimal area (e.g. typing "5" produced "$0.5" instead of "$5").

  • Detect this case in preValidation and redirect to the integer part when the field has no entered digits
  • The check ignores positions populated by checkVal (generatedInput) and the negation symbol, so the fix also applies after typing "-" alone

Closes #2615, closes #1367

Test plan

  • Added 12 QUnit tests covering:
    • cursor at position 0 with empty field
    • cursor at 0 after typing -
    • cursor at 0 after deleting all content
    • digitsOptional: false variant
    • non-regression: cursor at 0 when digits already present
    • multi-digit typing at position 0
    • alternative radixPoint/groupSeparator
    • full-width digit input
    • multi-character prefix ("$ ") with cursor at 0 and mid-prefix
    • multi-digit non-regression with existing value

AI disclosure

This PR was written primarily by Claude Code. Follow-up fixes were reviewed and amended by Codex.

…obinHerbots#2615)

When the cursor is placed before the prefix on a numeric mask with
radixPoint, the DOM position translates past the buffer end, causing
_isValid to fall through to alternation switching and place the digit
in the decimal area (e.g. typing "5" produced "$0.5" instead of "$5").

Detect this case in preValidation and redirect to the integer part
when the field has no entered digits. The check ignores positions
populated by checkVal (generatedInput) and the negation symbol so the
fix also applies after typing "-" alone.
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.

Currency alias. Move carret before prefix by arrows, input not work. Numeric input with prefix (currency) caret issue

1 participant