Repository navigation
fix(phone): ignore iPad Return key in VerificationCodeInputField - #1408
amansingh1207 wants to merge 2 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This pull request configures the return key type to .done for the verification code input field and handles the Return key behavior to support iPad hardware keyboards. The review feedback correctly points out that ignoring newlines and carriage returns in shouldChangeCharactersIn will break pasting verification codes that contain trailing newlines (e.g., from SMS or email), and recommends removing this check.
| // Ignore Return/newline (iPad hardware keyboard) — not a digit, not a delete. | ||
| if string.contains("\n") || string.contains("\r") { | ||
| return false | ||
| } |
There was a problem hiding this comment.
Checking string.contains("\n") or string.contains("\r") and returning false will prevent users from pasting verification codes that contain trailing newlines or carriage returns (which is very common when copying from SMS or email). Since the subsequent digitsOnly check already filters out non-digit characters and returns false if no digits are present, this check is redundant for single Return key presses and breaks pasting. Removing this check preserves the paste functionality while textFieldShouldReturn correctly handles the Return key.
There was a problem hiding this comment.
Agreed — removed newline guard. digitsOnly already blocks lone Return and preserves paste with trailing newline. textFieldShouldReturn handles iPad hardware Return.
Return from iPad hardware keyboard must resign without mutating digitFields. Previously repeated Return could clear/backspace through OTP boxes. Add textFieldShouldReturn -> resign + return false, explicit newline guard in shouldChangeCharactersIn, and returnKeyType .done.
faa27cc to
7fa3d44
Compare
Paste of '123456\n' from SMS/email must still work - digitsOnly filter already rejects lone Return. textFieldShouldReturn handles iPad hardware Return.
Fixes #1407. iPad hardware Return now resigns via textFieldShouldReturn without mutating digitFields; returnKeyType .done. No newline guard - digitsOnly filter already blocks lone Return and preserves paste of 123456\n from SMS/email.