SwiftUI TextField suggest OTP code without textContentType

Viewed 1203

I have a strange behavior in my SwiftUI project when using the TextField view.

With the following code, the TextField textContentType is set to nil (or .none, or UITextContentType.init(rawValue: "")) but the keyboard suggest me an OTP code (if received recently, for example in the previous view). Why ?

I've try other valid textContentType like .name, .address, ... with no success (only textContentType .password and .newPassword disable the OTP suggestion).

struct TestView: View {
    @State private var text: String = ""
    
    var body: some View {
        TextField("", text: $text)
            .keyboardType(.numberPad)
            .textContentType(nil) // or .none, or UITextContentType.init(rawValue: "")
    }
}

With a UIKit project, UITextField works as expected (no keyboard suggestion). Any ideas ?

Thanks

1 Answers

Apparently it's a carryover bug from UIKit. Same problem there.

thanks for the tip with .password

sadly that bring on suggestion to fill in passwords

Related