Browse Source

Merge pull request #586 from deltachat/searchScrollTop

chat list scrolls up on search input + cancel actions
cyBerta 5 years ago
parent
commit
39cedcea24
1 changed files with 8 additions and 0 deletions
  1. 8 0
      deltachat-ios/Controller/ChatListController.swift

+ 8 - 0
deltachat-ios/Controller/ChatListController.swift

@@ -368,5 +368,13 @@ extension ChatListController: UISearchBarDelegate {
     func searchBarCancelButtonClicked(_ searchBar: UISearchBar) {
         // searchBar will be set to "" by system
         viewModel.endSearch()
+        DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) {
+           self.tableView.scrollToTop()
+        }
+    }
+
+    func searchBar(_ searchBar: UISearchBar, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
+        tableView.scrollToTop()
+        return true
     }
 }