In iOS 16, suggested tokens remain visible when the query updates. I use this guide the user on what to type for more advanced queries. (e.g. if they type backslash, I give them a list of supported commands to use that will be tokenized "hasImage: true" for example).
In iOS 17, the suggested tokens disappear when the query is not empty. Does anyone know of a workaround? I've reported to Apple and hoping others are having this problem, so we can get it fixed before the betas are done.
It does not appear that the value of the suggested tokens state is changing, just that they are no longer visible.
Here's a minimum example, if you run on iOS 16 it runs as expected, on iOS17 it breaks
struct ContentView: View {
// MARK: Internal
struct Token: Identifiable, Equatable {
let text: String
var id: String {
text
}
}
var body: some View {
NavigationStack {
List {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundColor(.accentColor)
Text("Hello, world!")
}
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundColor(.accentColor)
Text("Hello, world!")
}
}
.navigationTitle("Search Suggestions")
.searchable(text: $query,
tokens: $tokens,
suggestedTokens: $suggestions,
placement: .toolbar, prompt: "Search") { token in
Text(token.text)
}
}
}
// MARK: Private
@State private var query: String = ""
@State private var suggestions: [Token] = [Token(text: "One"), Token(text: "Two")]
@State private var tokens: [Token] = []
}