I don't know if this is a bug but when you put text fiels in a form, pressing the Tab key on a physical keyboard will just jump to the first field and stay there:
import SwiftUI
struct ContentView: View {
enum FocusedField {
case firstName, lastName
}
@State var name = ""
@State var lastName = ""
@FocusState private var focusedField: FocusedField?
var body: some View {
Form {
TextField("Name", text: $name)
.focused($focusedField, equals: .firstName)
TextField("Last", text: $lastName)
.focused($focusedField, equals: .lastName)
}
.padding()
.onAppear {
focusedField = .firstName
}
}
}
This is the result:
Note that this works fine on macOS or when using the Tab key on the virtual keyboard.
If you put the fields into a VStack instead, you'll be able to move through the fields via the Tab key.