Save credentials prompt not shown when login and password aren't the last fields in a form

The save credentials prompt is not shown after clicking the submit button in the following setup. The prompt is shown if I move the email field before the login field.

Is it really required to have login and password fields at the end of the registration form? Or is there some API that can trigger the prompt?

struct FakeRegistrationView: View {
    @State private var login = ""
    @State private var password = ""
    @State private var repeatPassword = ""
    @State private var email = ""

    var navigateBack: () -> Void

    var body: some View {
        VStack(spacing: 16) {
            TextField("Login", text: $login)
                .textFieldStyle(.roundedBorder)
                .textContentType(.username)
                .disableAutocorrection(true)
                .autocapitalization(.none)
                .frame(maxWidth: 300)

            SecureField("Password", text: $password)
                .textFieldStyle(.roundedBorder)
                .textContentType(.newPassword)
                .disableAutocorrection(true)
                .autocapitalization(.none)
                .frame(maxWidth: 300)

            SecureField("Repeat password", text: $repeatPassword)
                .textFieldStyle(.roundedBorder)
                .textContentType(.newPassword)
                .disableAutocorrection(true)
                .autocapitalization(.none)
                .frame(maxWidth: 300)

            TextField("Email", text: $email)
                .textFieldStyle(.roundedBorder)
                .textContentType(.emailAddress)
                .disableAutocorrection(true)
                .autocapitalization(.none)
                .frame(maxWidth: 300)

            Button {
                Task {
                    try? await Task.sleep(for: .seconds(2))
                    navigateBack()
                }
            } label: {
                Text("Submit")
            }
            .buttonStyle(.borderedProminent)
        }
    }
}

The order of the fields shouldn't matter – If they do, it will be a bug and I’d suggest that you file a feedback report and share your report ID here.

Your code snippet isn't quite enough for analyzing the issue – It doesn't show what navigateBack() does and how you present the sheet. If you can provide a minimal project that reproduces the issue. I may be able to take a closer look. Your post can contain a link to where your test project is hosted.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Save credentials prompt not shown when login and password aren't the last fields in a form
 
 
Q