I want to put a search field into the sidebar, but for some reason when using placement: .sidebar
, the cursor always jumps to the end of the text. So if I want to add a word to the start of the search query, after typing one letter, the cursor jumps to the end.
Here is some minimal code to reproduce this issue:
struct ContentView: View {
@State var selection = ""
@State var searchText = ""
var body: some View {
NavigationSplitView {
List(selection: $selection) {
Text("First")
.tag("first")
Text("Second")
.tag("second")
Text("Thrid")
.tag("third")
}
} detail: {
VStack {
Text("Detail page for: \(selection)")
Text("Searching for: \(searchText)")
}
}
.searchable(text: $searchText, placement: .sidebar)
}
}
macOS version: 13.4.1
Xcode version: 14.3.1
In the macOS Sonoma (14.0) update, this problem is now fixed.