Username & Password Autofill on Mac Application From Safari Only Fills 1 Field at a Time

Originator:developer.computers
Number:rdar://FB9184880 Date Originated:2021-06-16
Status:Open Resolved:
Product:SwiftUI/Password Autofill Product Version:SwiftUI 2.0
Classification:Incorrect/Unexpected Behavior Reproducible:Yes
 
Link to our app for initial reproduction: https://apps.apple.com/us/app/sparta-scan/id1538862847?mt=12
 
Expected Behavior:
    Choosing a password to fill should fill both the username field AND the password field.

Observed Behavior:
    Choosing a password to fill only fills out the individual field that was active/focused before going into the "Passwords..." flow that allows the user to autofill credentials that were previously saved in Safari. We have tried on iMac and MacBook Pro (intel) and it is reproducible for us 100% of the time.

Reproduction Steps:
1. Have some passwords saved in Safari to allow the "Passwords..." modal to pop up when clicking on the username or password fields in the form
2. Bring up the "Passwords..." modal by clicking on the form and beginning to type and click on it
3. Authenticate with the computer user's password to allow access to saved passwords
4. Pick a password
5. Observe that only the username OR password field are filled out

import SwiftUI
import Testable

struct LoginPanelView: View {
    @Binding var email: String
    @Binding var password: String
    @Binding var serverEnvironment: ServerEnvironment
    let onLoginAction: ActionCompletion

    var body: some View {
        VStack(spacing: 8) {
            Text("Sparta Scan")
                .font(.largeTitle)
                .padding(.bottom, 20)
            #if DEBUG
            Picker(selection: $serverEnvironment, label: EmptyView()) {
                ForEach(ServerEnvironment.allCases) {
                    Text($0.rawValue).tag($0)
                }
            }.accessibilityIdentifier("select server")
            #endif
            TextField("Email", text: $email)
                .textContentType(.username)
            SecureField("Password", text: $password)
                .textContentType(.password)
            Button("Login", action: onLoginAction)
                .padding(.top, 20)
                .disabled(email.isEmpty || password.isEmpty)
                .keyboardShortcut(.defaultAction)
        }
        .padding()
        .background(Color.panelBackground)
        .cornerRadius(8)
    }
}

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!