Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/iOS/CustomViews/AutocompleteTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}

Expand Down
Loading