From 5c71b7ef45f2f1b4a0daa74bdad5c5f3f93f1f18 Mon Sep 17 00:00:00 2001 From: Nathan Mattes Date: Wed, 20 Sep 2023 19:59:46 +0200 Subject: [PATCH] Search for everything when user taps "search" on keyboard (IOS-141) --- .../SearchResultsOverviewTableViewController.swift | 1 + .../Search/SearchDetail/SearchDetailViewController.swift | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/Mastodon/Scene/Search/SearchDetail/Search Results Overview/SearchResultsOverviewTableViewController.swift b/Mastodon/Scene/Search/SearchDetail/Search Results Overview/SearchResultsOverviewTableViewController.swift index db38027bc..ff6c8c621 100644 --- a/Mastodon/Scene/Search/SearchDetail/Search Results Overview/SearchResultsOverviewTableViewController.swift +++ b/Mastodon/Scene/Search/SearchDetail/Search Results Overview/SearchResultsOverviewTableViewController.swift @@ -34,6 +34,7 @@ class SearchResultsOverviewTableViewController: UIViewController, NeedsDependenc self.coordinator = sceneCoordinator tableView = UITableView(frame: .zero, style: .insetGrouped) + tableView.keyboardDismissMode = .onDrag tableView.translatesAutoresizingMaskIntoConstraints = false tableView.backgroundColor = .systemGroupedBackground tableView.separatorInset.left = 62 diff --git a/Mastodon/Scene/Search/SearchDetail/SearchDetailViewController.swift b/Mastodon/Scene/Search/SearchDetail/SearchDetailViewController.swift index 82cb9795f..f61b47265 100644 --- a/Mastodon/Scene/Search/SearchDetail/SearchDetailViewController.swift +++ b/Mastodon/Scene/Search/SearchDetail/SearchDetailViewController.swift @@ -265,7 +265,12 @@ extension SearchDetailViewController: UISearchBarDelegate { } func searchBarSearchButtonClicked(_ searchBar: UISearchBar) { + guard let searchText = searchBar.text, searchText.isNotEmpty else { return } + searchBar.resignFirstResponder() + + let searchResultViewModel = SearchResultViewModel(context: context, authContext: viewModel.authContext, searchScope: .all, searchText: searchText) + coordinator.present(scene: .searchResult(viewModel: searchResultViewModel), transition: .show) } func searchBarCancelButtonClicked(_ searchBar: UISearchBar) {