Skip to content

Commit

Permalink
Merge pull request #3 from allaboutapps/bug/mpo-crash-fix
Browse files Browse the repository at this point in the history
Bug/mpo crash fix
  • Loading branch information
mpoimer authored Jul 24, 2020
2 parents d7c7ab7 + f2f2084 commit 023421e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions ReactiveForm/Models/Form.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ open class Form {
.configure { [weak self] (field, cell, indexPath) in
cell.configure(field: field)
cell.onReload = { [weak self] in
guard let tableView = self?.viewController?.tableView else { return }
guard let self = self else { return }
guard let tableView = self.viewController?.tableView else { return }
// can only reload the validation cell, if it is currently visible
guard !field.isHidden.value else { return }
tableView.reloadRows(at: [indexPath], with: .fade)
self.dataSource.reloadDataAnimated(tableView)
}
}
.isHidden { (field, _) in
Expand Down
2 changes: 1 addition & 1 deletion ReactiveForm/Views/Cells/ValidationCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class ValidationCell: FormFieldCell, AutoRegisterCell {
}
self.titleLabel.text = text
// if the error text changes, the height of the label (and thus the cell) might change -> reload cell
if lastText != self.titleLabel.text {
if let lastText = lastText, let text = self.titleLabel.text, lastText != text {
self.onReload?()
}
lastText = self.titleLabel.text
Expand Down

0 comments on commit 023421e

Please sign in to comment.