Repository navigation
[@mantine/core] PinInput: Fix readOnly not preventing value changes on Delete, Backspace and paste - #9258
Merged
Conversation
…n Delete, Backspace and paste
Member
|
🤖 Beep boop, Claude (Fable 5.1) speaking! Pull request is perfect, no changes needed! Verified label added. |
Member
|
Thanks! |
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.
Bug
PinInputwithreadOnlycan still be edited.readonlyis set on each<input>, butPinInputhandles Delete, Backspace and paste itself, and those handlers update the value without checkingreadOnly. Delete and Backspace clear the focused field, and pasting a valid code replaces the whole value.Fix
In
PinInput.tsx, whenreadOnlyis set:handleKeyDownno longer clear a field (Backspace also no longer moves focus back, since nothing is deleted).handlePastereturns afterpreventDefault()without setting values.Arrow keys still move focus between fields. Typing was already blocked by the native
readonlyattribute.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 navigationguards that navigation still works.PinInputsuites: 98 passed.oxlintandformat:write:filesare clean, and roottsc --noEmitreports no@mantine/coreerrors.