Fix not committing URL when pressing return
This commit is contained in:
parent
92fe14cd9b
commit
040a799b7b
|
@ -14,7 +14,7 @@ class NavigationBarView: UIView {
|
|||
let navigator: NavigationManager
|
||||
|
||||
private var border: UIView!
|
||||
private var textField: UITextField!
|
||||
private(set) var textField: UITextField!
|
||||
|
||||
private var cancellables = [AnyCancellable]()
|
||||
|
||||
|
@ -40,9 +40,10 @@ class NavigationBarView: UIView {
|
|||
textField.text = navigator.displayURL
|
||||
textField.borderStyle = .roundedRect
|
||||
textField.keyboardType = .URL
|
||||
textField.returnKeyType = .go
|
||||
textField.autocapitalizationType = .none
|
||||
textField.autocorrectionType = .no
|
||||
textField.addTarget(self, action: #selector(commitURL), for: .editingDidEnd)
|
||||
textField.addTarget(self, action: #selector(commitURL), for: .primaryActionTriggered)
|
||||
textField.translatesAutoresizingMaskIntoConstraints = false
|
||||
addSubview(textField)
|
||||
NSLayoutConstraint.activate([
|
||||
|
@ -75,6 +76,7 @@ class NavigationBarView: UIView {
|
|||
}
|
||||
|
||||
@objc private func commitURL() {
|
||||
textField.resignFirstResponder()
|
||||
if let text = textField.text, let url = URL(string: text) {
|
||||
navigator.changeURL(url)
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue