Skip to content

[@mantine/core] PinInput: Fix readOnly not preventing value changes on Delete, Backspace and paste - #9258

Merged
rtivital merged 1 commit into
mantinedev:masterfrom
lavinhoque33:fix/pin-input-read-only
Oct 11, 2026
Merged

rtivital merged 1 commit into
mantinedev:masterfrom
lavinhoque33:fix/pin-input-read-only

Conversation

@lavinhoque33

Copy link
Copy Markdown
Contributor

Bug

PinInput with readOnly can still be edited. readonly is set on each <input>, but PinInput handles Delete, Backspace and paste itself, and those handlers update the value without checking readOnly. Delete and Backspace clear the focused field, and pasting a valid code replaces the whole value.

Fix

In PinInput.tsx, when readOnly is set:

  • Delete and Backspace in handleKeyDown no longer clear a field (Backspace also no longer moves focus back, since nothing is deleted).
  • handlePaste returns after preventDefault() without setting values.

Arrow keys still move focus between fields. Typing was already blocked by the native readonly attribute.

Closes #9256

Testing

  • PinInput.test.tsx: readOnly does not change value on Delete, which fails on master (['', '2', '3', '4']) and passes with the fix.
  • PinInput.test.tsx: readOnly does not change value on Backspace, which fails on master and passes with the fix.
  • PinInput.test.tsx: readOnly does not change value on paste, which fails on master and passes with the fix.
  • PinInput.test.tsx: readOnly keeps arrow key focus navigation guards that navigation still works.
  • PinInput suites: 98 passed. oxlint and format:write:files are clean, and root tsc --noEmit reports no @mantine/core errors.

@rtivital rtivital added the Verified Reviewed and verified PR label Oct 11, 2026
@rtivital

Copy link
Copy Markdown
Member

🤖 Beep boop, Claude (Fable 5.1) speaking! Pull request is perfect, no changes needed! Verified label added.

@rtivital
rtivital merged commit 27cc947 into mantinedev:master Oct 11, 2026
1 check passed
@rtivital

Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Verified Reviewed and verified PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PinInput: readOnly does not prevent changes via Delete, Backspace and paste

2 participants