Keyboard doesn't close if QuickType bar is open for password auto-fill in SwiftUI when using associated domains.

Description

Our app (and sample app) are using associated domains to support deep linking. As an unintended side effect we get full support for auto-filling passwords with the QuickType bar on our login screen. However, after the username and password fields are filled and the user taps the Login button, the keyboard stays on screen. We have tried everything I can think of including @FocusState UIKit resignFirstResponder, and many other iterations of testing.

Our login screen is in a fullscreencover or sheet. When the sheet dismisses the keyboard stays. In my sample app if I use a navigation stack and push the next view onto the stack, the keyboard closes.

I can't provide a useful video because the iOS screen recorder will hide the keyboard when focus is in a SecureField.

Note: If we remove the associated domain from the project everything works as expected.

Code Example

struct ContentView: View {
  @State private var name: String = ""
  @State private var password: String = ""
  @State private var showLogin = false

  @FocusState private var isFocused: Bool

  var body: some View {
    VStack {
      Button("Login") {
        showLogin.toggle()
      }
    }
    .fullScreenCover(isPresented: $showLogin) {
      VStack {
        TextField("Enter your name", text: $name)
          .textFieldStyle(.roundedBorder)
          .focused($isFocused)

        SecureField("Enter password", text: $password)
          .autocapitalization(.none)
          .autocorrectionDisabled(true)
          .textContentType(.password)
          .focused($isFocused)

        Button("Login") {
          isFocused = false
          showLogin = false
        }
        .buttonStyle(.borderedProminent)

      }
    }
  }
}

Steps to Reproduce

  1. Launch sample app
  2. Tap 'Login'
  3. Place keyboard focus in the first text field (name)
  • Keyboard with QuickType bar opens
    
  1. Tap 'Passwords'
  2. Create a new password for this login item (choose any username)
  • Passwords will close
    
  1. Tap 'Login' to close the sheet
  2. Force close the app
  3. Reopen the app
  4. Tap 'Login'
  5. Place keyboard focus in the first text field (name)
  • Keyboard with QuickType” bar opens
    
  1. Tap the auto-fill password button (password for atomicrobot.com in my case)
  • User name and password fields are filled out
    
  • Keyboard with QuickType bar is still open; keyboard focus is in "password" field
    
  1. Tap 'Login'
  • Sheet closes, keyboard is still open
    

Thanks so much for your post. I see you also sent us a code-level support request.

In response to your inquiry regarding the code-level support, I have sent you an email. To maintain privacy, I would like to continue our conversation via email, unless that’s not your preference. Please provide me with the AASA file and applinks configuration as per my email request.

Albert Pascual
  Worldwide Developer Relations.

I've had this exact same problem, did you guys manage to come to any fix? I've tried searching several forms and nothing is working sadly. Let me know as it's the most annoying bug and it's the last one I've got to get through. Thanks in advance!

Keyboard doesn't close if QuickType bar is open for password auto-fill in SwiftUI when using associated domains.
 
 
Q