Skip to content

Fix 2FA code paste and macOS autofill in PIN code input#820

Open
rursache wants to merge 1 commit into
XcodesOrg:mainfrom
rursache:fix/2fa-paste-and-autofill
Open

Fix 2FA code paste and macOS autofill in PIN code input#820
rursache wants to merge 1 commit into
XcodesOrg:mainfrom
rursache:fix/2fa-paste-and-autofill

Conversation

@rursache

Copy link
Copy Markdown

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 PinCodeTextView around the standard one-time code pattern: a single invisible NSTextField with contentType = .oneTimeCode overlays 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 public PinCodeTextField SwiftUI 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 insertText and external reset via the binding. App builds and runs.

Fixes #587
Fixes #788

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
@MattKiazyk

Copy link
Copy Markdown
Contributor

Hi @rursache

Was this not fixed via #778 that is available in the latest 4.0.3 release?

@rursache

Copy link
Copy Markdown
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

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.

SMS Autofill doesn't work Pasting 2FA SMS codes will not fill all the textfields

2 participants