This commit is contained in:
Arkadiusz Fal 2022-03-26 15:22:29 +01:00
parent c8fa972a61
commit c14a4a153d
3 changed files with 11 additions and 1 deletions

View File

@ -141,6 +141,12 @@ final class NavigationModel: ObservableObject {
channelToUnsubscribe = channel channelToUnsubscribe = channel
presentingUnsubscribeAlert = channelToUnsubscribe != nil presentingUnsubscribeAlert = channelToUnsubscribe != nil
} }
func hideKeyboard() {
#if os(iOS)
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
#endif
}
} }
typealias TabSelection = NavigationModel.TabSelection typealias TabSelection = NavigationModel.TabSelection

View File

@ -29,7 +29,10 @@ struct SearchTextField: View {
.opacity(0.8) .opacity(0.8)
#endif #endif
TextField("Search...", text: $state.queryText) { TextField("Search...", text: $state.queryText) {
state.changeQuery { query in query.query = state.queryText } state.changeQuery { query in
query.query = state.queryText
navigation.hideKeyboard()
}
recents.addQuery(state.queryText, navigation: navigation) recents.addQuery(state.queryText, navigation: navigation)
} }
.onChange(of: state.queryText) { _ in .onChange(of: state.queryText) { _ in

View File

@ -75,6 +75,7 @@ struct SearchSuggestions: View {
state.changeQuery { query in state.changeQuery { query in
query.query = state.queryText query.query = state.queryText
state.fieldIsFocused = false state.fieldIsFocused = false
navigation.hideKeyboard()
} }
recents.addQuery(state.queryText, navigation: navigation) recents.addQuery(state.queryText, navigation: navigation)