Hey! It seems like the focus state is not working. I even tried copying the example from the documentation directly into a new view and it didn't select the different textFields. Anybody that can see anything that I am missing?
struct LoginForm: View {
enum Field: Hashable {
case username
case password
}
@State private var username = ""
@State private var password = ""
@FocusState private var focusedField: Field?
var body: some View {
Form {
TextField("Username", text: $username)
.focused($focusedField, equals: .username)
SecureField("Password", text: $password)
.focused($focusedField, equals: .password)
Button("Sign In") {
if username.isEmpty {
focusedField = .username
} else if password.isEmpty {
focusedField = .password
} else {
}
}
}
}
}