Fix 2FA code paste and macOS autofill in PIN code input#820
Open
rursache wants to merge 1 commit into
Open
Conversation
Replace the six independently focused NSTextFields with a single invisible input field (contentType = .oneTimeCode) overlaying display-only digit boxes. All input now lands in one field, so pasting a full code works from any state and the system one-time code autofill from Messages/Mail inserts the whole code instead of breaking after the first digit when focus jumped between fields. Fixes XcodesOrg#587, fixes XcodesOrg#788
Contributor
Author
|
just had the same issue but indeed i'm on 4.0.2 not 0.3. will check again and close the PR if that the case |
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
The 2FA/SMS code entry uses six independently focused text fields. Pasting a code only kept one digit (#587) and macOS one-time code autofill from Messages/Mail broke after the first digit because the system inserts the whole code into the focused field and the focus jumping between fields aborts the insertion (#788).
Fix
Rewrote
PinCodeTextViewaround the standard one-time code pattern: a single invisibleNSTextFieldwithcontentType = .oneTimeCodeoverlays the row and owns all input, while the digit boxes are display-only. Pasting now works from any state, the system autofill suggestion appears (field auto-focuses when the sheet opens) and inserts the full code, and pasting a full code over partially entered digits replaces them. The publicPinCodeTextFieldSwiftUI API is unchanged.Note: the SMS being deleted after autofill is the system "Clean Up Automatically" feature and not controllable by the app.
Testing
Verified with a headless harness driving the real field editor: paste into empty field, paste over partial input, paste with separators, digit by digit typing, backspace, overflow capping, autofill-style bulk
insertTextand external reset via the binding. App builds and runs.Fixes #587
Fixes #788