struct ContentView: View {
@State private var editTitle = "title"
@FocusState private var isFocused: Bool
var body: some View {
NavigationSplitView {
Text("sidebar")
} detail: {
Text("detail")
.navigationTitle("")
.toolbar {
ToolbarItem(placement: .principal) {
TextField("", text: $editTitle)
.focused($isFocused)
.onChange(of: isFocused) { oldValue, newValue in
print("onChange")
}
}
}
}
}
}
- on iOS, onChange is triggerred when TextField is inside toolbar or not
- on MacOS, onChange is not triggerred when TextField is inside toolbar, but when not in toolbar, it works fine