CHanging @FocusState on searchable doesn't make it focused

320 views Asked by At

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)
    }
}
0

There are 0 answers