Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start editing field rows at the end when tapping blank space in row #2046

Merged
merged 3 commits into from
Jun 15, 2020
Merged
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
9 changes: 7 additions & 2 deletions Source/Rows/Common/FieldRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ open class _FieldCell<T> : Cell<T>, UITextFieldDelegate, TextFieldCell where T:
}
textField.addTarget(self, action: #selector(_FieldCell.textFieldDidChange(_:)), for: .editingChanged)

if let titleLabel = titleLabel {
// Make sure the title takes over most of the empty space so that the text field starts editing at the back.
let priority = UILayoutPriority(rawValue: titleLabel.contentHuggingPriority(for: .horizontal).rawValue + 1)
textField.setContentHuggingPriority(priority, for: .horizontal)
}
}

open override func update() {
Expand Down Expand Up @@ -261,11 +266,11 @@ open class _FieldCell<T> : Cell<T>, UITextFieldDelegate, TextFieldCell where T:
}

open override func cellBecomeFirstResponder(withDirection: Direction) -> Bool {
return textField?.becomeFirstResponder() ?? false
return textField.becomeFirstResponder()
}

open override func cellResignFirstResponder() -> Bool {
return textField?.resignFirstResponder() ?? true
return textField.resignFirstResponder()
}

open override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
Expand Down