.textContentType(.emailAddress) does not work as expected

The following code:

struct ContentView: View { @State private var email = ""

var body: some View {
    VStack {
        TextField("email", text: $email)
            .textContentType(.emailAddress)
    }
}

}

does not work as expected. What I expected is to run the app and have it suggest my actual email when I click into the field. Instead what it does is display "Hide My Email" twice. Selecting the first "Hide My Email" pastes the actual text "Hide My Email" into the field, the second one brings up an iCloud sheet to select a random email.

Trying some suggestions online for .emailAddress in general not working does not change anything:

TextField("Email", text: $email) .textFieldStyle(RoundedBorderTextFieldStyle()) .textContentType(.emailAddress) .keyboardType(.emailAddress) .autocorrectionDisabled() .disableAutocorrection(true) .textInputAutocapitalization(.never)

I did some experimenting and this looks like a bug in how iOS is handling the logic here — there are some odd behaviors.

If you go to Contacts → [your contact card], that seems to be one of the sources iOS pulls email addresses from. In my case I tried a few combinations: • Added just a Home email → wouldn’t show • Added just a Work email → wouldn’t show • Added both Home and Work → the Work email always shows

It doesn’t seem to matter what I actually put in for the email, it consistently behaves that way.

.textContentType(.emailAddress) does not work as expected
 
 
Q