Skip to content

fix(inputmask): prevent digit shift across section boundaries on delete#1

Open
ehsanshrz wants to merge 1 commit into
masterfrom
fix/inputmask-shift-across-sections
Open

fix(inputmask): prevent digit shift across section boundaries on delete#1
ehsanshrz wants to merge 1 commit into
masterfrom
fix/inputmask-shift-across-sections

Conversation

@ehsanshrz

Copy link
Copy Markdown
Owner

When using InputMask with a segmented pattern like '99.99.9999', pressing
Backspace or Delete inside one section would shift digits from subsequent
sections into the current one, causing values like '10.04.2026' to bleed
across the '.' separators.

Root cause: shiftL() iterated with seekNext() which skips over fixed mask
characters (null entries in the tests array). This allowed the left-shift
loop to pull digits across separator boundaries.

Fix: Added a countFixedChars() helper that counts null (fixed) positions in
a range. Before each shift step, we compare the number of fixed characters
encountered on the destination side (begin..i) vs. the source side
(end+1..j). If they differ, the shift has crossed a section boundary and
we break early.

The fix is applied to both the InputMask directive and the InputMask
standalone component classes.

Fixes primefaces#19629
@ehsanshrz ehsanshrz force-pushed the fix/inputmask-shift-across-sections branch from 4660027 to dfc1680 Compare June 16, 2026 10:55
@github-actions

Copy link
Copy Markdown

Thank you for your contribution! We will review your PR shortly. Please make sure to manually link it to an issue for proper tracking.

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.

DatePicker inputMask shifts digits between date sections when deleting

1 participant