diff --git a/src/iOS/CustomViews/AutocompleteTextField.swift b/src/iOS/CustomViews/AutocompleteTextField.swift index c176c1834..667a16724 100644 --- a/src/iOS/CustomViews/AutocompleteTextField.swift +++ b/src/iOS/CustomViews/AutocompleteTextField.swift @@ -34,6 +34,11 @@ class AutocompleteTextField: UITextField, UITextFieldDelegate, UITableViewDataSo selector: #selector(keyboardWillChange(_:)), name: UIResponder.keyboardWillChangeFrameNotification, object: nil) + NotificationCenter.default.addObserver( + self, + selector: #selector(appWillResignActive(_:)), + name: UIApplication.willResignActiveNotification, + object: nil) super.delegate = self } @@ -127,6 +132,12 @@ class AutocompleteTextField: UITextField, UITextFieldDelegate, UITableViewDataSo } } + @objc func appWillResignActive(_ nsNotification: Notification) { + guard !filteredCompletions.isEmpty else { return } + + clearFilteredCompletionsInternal() + } + func frameForCompletionTableView() -> CGRect { guard let cell = superviewOfType(UITableViewCell.self), let tableView = cell.superviewOfType(UITableView.self) @@ -274,6 +285,12 @@ class AutocompleteTextField: UITextField, UITextFieldDelegate, UITableViewDataSo func textFieldDidEndEditing(_ textField: UITextField) { clearFilteredCompletionsInternal() + if let cell = superviewOfType(UITableViewCell.self), + let tableView = cell.superviewOfType(UITableView.self) + { + tableView.isScrollEnabled = true + } + realDelegate?.textFieldDidEndEditing?(textField) }