outrowender
outrowender

Reputation: 401

SwiftUI app makes the keyboard flicker if TextField is in password content mode

As the title says, the keybord will flicker when I use .textContentType(.password). I have no idea what is going on and this is very distractive for the users. It only happens in real devices and not the iOS Simulator. I have tested both my iPhone 12 and my wife's 15 Pro and it happens a lot more in my 12. Both running iOS 17.6.1.

First I thought it was related to state management or some of my layout, but I set a minimal app and still happening.

Here is the code

struct ContentView: View {
    @FocusState var inFocus: String?
    @State var password: String = ""
    
    var body: some View {
        VStack {
            Spacer().frame(height: 50)
            
            Image(systemName: "globe")
                .imageScale(.large)
                .foregroundStyle(.tint)
            Text("Hello, world!")
            
            Spacer()
            
            TextField("my pass", text: $password, prompt: Text("placeholder 2"))
                .focused($inFocus, equals: "password")
                .keyboardType(.emailAddress)
                .textContentType(.password)
                .textInputAutocapitalization(.never)
                .id("pass1")
        }
        .padding()
    }
}

Upvotes: 0

Views: 58

Answers (0)

Related Questions