Already filed a feedback in case this is a bug, but posting here in case I'm doing something wrong?
I'd like the search field to automatically be displayed with the keyboard up when the view appears. This sample code works in iOS 18, but it does not work in iOS 26 beta 7
I also tried adding a delay to setting searchIsFocused = true
but that did not help
struct ContentView: View {
var body: some View {
NavigationStack {
NavigationLink(destination: ListView()) {
Label("Go to list", systemImage: "list.bullet")
}
}
.ignoresSafeArea()
}
}
struct ListView: View {
@State private var searchText: String = ""
@State private var searchIsPresented: Bool = false
@FocusState private var searchIsFocused: Bool
var body: some View {
ScrollView {
Text("Test")
}
.searchable(text: $searchText, isPresented: $searchIsPresented, placement: .automatic, prompt: "Search")
.searchFocused($searchIsFocused)
.onAppear {
searchIsFocused = true
}
}
}