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
- Launch sample app
- Tap 'Login'
- Place keyboard focus in the first text field (name)
-
Keyboard with QuickType bar opens
- Tap 'Passwords'
- Create a new password for this login item (choose any username)
-
Passwords will close
- Tap 'Login' to close the sheet
- Force close the app
- Reopen the app
- Tap 'Login'
- Place keyboard focus in the first text field (name)
-
Keyboard with QuickType” bar opens
- 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
- Tap 'Login'
-
Sheet closes, keyboard is still open