From 7fa3d443634a966e5d53d9137ad2d3e3004c35e7 Mon Sep 17 00:00:00 2001 From: Aman Singh Date: Tue, 13 Oct 2026 00:20:28 +0530 Subject: [PATCH 1/2] fix(phone): ignore iPad Return key in VerificationCodeInputField 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. --- .../Components/VerificationCodeInputField.swift | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/FirebaseSwiftUI/FirebaseAuthUIComponents/Sources/Components/VerificationCodeInputField.swift b/FirebaseSwiftUI/FirebaseAuthUIComponents/Sources/Components/VerificationCodeInputField.swift index cc226a33c32..3c71863f112 100644 --- a/FirebaseSwiftUI/FirebaseAuthUIComponents/Sources/Components/VerificationCodeInputField.swift +++ b/FirebaseSwiftUI/FirebaseAuthUIComponents/Sources/Components/VerificationCodeInputField.swift @@ -334,6 +334,7 @@ private struct SingleDigitField: View { textField.font = .systemFont(ofSize: 24, weight: .medium) textField.textAlignment = .center textField.keyboardType = .numberPad + textField.returnKeyType = .done textField.textContentType = .oneTimeCode textField.autocapitalizationType = .none textField.autocorrectionType = .no @@ -457,9 +458,20 @@ private struct BackspaceAwareTextField: UIViewRepresentable { } } + func textFieldShouldReturn(_ textField: UITextField) -> Bool { + // iPad hardware keyboard: never delete/hide fields on Return. + textField.resignFirstResponder() + return false + } + func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { + // Ignore Return/newline (iPad hardware keyboard) — not a digit, not a delete. + if string.contains("\n") || string.contains("\r") { + return false + } + if string.isEmpty { return true } From 65aa7245bfcd2148fd7f26a1f0b76312d7efe07c Mon Sep 17 00:00:00 2001 From: Aman Singh Date: Tue, 13 Oct 2026 00:22:22 +0530 Subject: [PATCH 2/2] fix(phone): drop newline guard, keep textFieldShouldReturn Paste of '123456\n' from SMS/email must still work - digitsOnly filter already rejects lone Return. textFieldShouldReturn handles iPad hardware Return. --- .../Sources/Components/VerificationCodeInputField.swift | 5 ----- 1 file changed, 5 deletions(-) diff --git a/FirebaseSwiftUI/FirebaseAuthUIComponents/Sources/Components/VerificationCodeInputField.swift b/FirebaseSwiftUI/FirebaseAuthUIComponents/Sources/Components/VerificationCodeInputField.swift index 3c71863f112..0092ee04963 100644 --- a/FirebaseSwiftUI/FirebaseAuthUIComponents/Sources/Components/VerificationCodeInputField.swift +++ b/FirebaseSwiftUI/FirebaseAuthUIComponents/Sources/Components/VerificationCodeInputField.swift @@ -467,11 +467,6 @@ private struct BackspaceAwareTextField: UIViewRepresentable { func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { - // Ignore Return/newline (iPad hardware keyboard) — not a digit, not a delete. - if string.contains("\n") || string.contains("\r") { - return false - } - if string.isEmpty { return true }