Reputation: 21005
When the search becomes active i get a callback with .onChange(of: isFocused
but setting isFocused
to false doesn't make the search inactive
struct MainSearchable: ViewModifier {
@State var searchText: String = ""
@FocusState private var isFocused: Bool
func body(content: Content) -> some View {
content
.searchable(text: $searchText, placement: .toolbar)
.searchSuggestions {
...
}
.onChange(of: isFocused, perform: { newValue in
print("FOCUSED")
})
.onSubmit(of: .search) {
...
}
.focused($isFocused)
}
}
Upvotes: 1
Views: 464