I have a SwiftUI app that runs on both iOS and macOS. We utilize the .focused
modifier to determine what fields are currently active. After updating our machines to macOS 14 it seems like the .focused
modifier is broken for TextFields that utilize a .vertical
axis as well as for TextEditor
Multiline text edit is critical for us, but now we're unable to save data entered. Is this a known issue with macOS 14 or somehow intentional?
Below is an example:
struct ContentView: View {
@FocusState private var isEmailFocused: Bool
@State private var email = ""
var body: some View {
NavigationView {
Form {
TextEditor(text: $email)
.focused($isEmailFocused)
}
.navigationTitle("Sign in")
.onChange(of: isEmailFocused) { newValue in
print(newValue)
}
}
}
}
struct ContentView: View {
@FocusState private var isEmailFocused: Bool
@State private var email = ""
var body: some View {
NavigationView {
Form {
TextField("Address", text: $email, axis: .vertical)
.focused($isEmailFocused)
}
.navigationTitle("Sign in")
.onChange(of: isEmailFocused) { newValue in
print(newValue)
}
}
}
}
This functionality worked flawlessly in macOS 13.