UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

TextField gets hidden by the keyboard when tapped if the previous field on focus, used the default keyboard

Forums > SwiftUI

I'm not sure if this a bug or not but for some reason Field 5 is hidden by the keyboard as soon as it is tapped. The funny thing is that it only happens if the previous field in focus used the default keyboard.

To reproduce the issue I'm describing, first tap on Field 1 or Field 4 then go down and tap on Field 5.

Any idea how can this be fixed?

struct TextFieldScrollingIssue: View {
    @State private var testInput:String = ""
    @State private var decimalInput:String = ""

    var body: some View {
        VStack{
            Form {
                TextField("Field 1", text:$testInput)
                    .id("Field 1")
                    .keyboardType(.default)
                Spacer()
                Spacer()
                Spacer()
                Spacer()
                Spacer()
                Spacer()
                Section(header: Text("Section 2: ")) {
                    TextField("Field 2", text:$testInput)
                        .id("Field 2")
                        .keyboardType(.decimalPad)

                    TextField("Field 3", text:$decimalInput)
                        .id("Field 3")
                        .keyboardType(.decimalPad)
                }

                Section(header: Text("Section 3: ")) {
                    TextField("Field 4", text:$testInput)
                        .id("Field 4")
                        .keyboardType(.default)

                    TextField("Field 5", text:$decimalInput)
                        .id("Field 5")
                        .keyboardType(.decimalPad)
                }
            }
        }
    }
}

1      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.