Closed rgravina closed 3 years ago
Also credit to @kayleema for discovering this, not me :)
Thanks for this one, too @rgravina! And thanks to @kayleema as well - Kaylee please feel free to open issues and make PRs as well if you like! The more community support we can generate, the better Succinct can become! 😃
So far as I know, when I built the tapCell
functionality, in order for it to work properly it was required to call both the selectRow
method as well as the delegate method for didSelectRow
, therefore the current implementation is as follows:
if let cell = tableView.dataSource?.tableView(tableView, cellForRowAt: indexPath) {
if let _ = cell.findLabel(withExactText: searchText) {
tableView.selectRow(at: indexPath, animated: false, scrollPosition: .none)
tableView.delegate?.tableView?(tableView, didSelectRowAt: indexPath)
}
}
Therefore, I believe that the delegate method that you've mentioned above is already being called from tapCell
. You can also verify the current code here: https://github.com/derekleerock/Succinct/blob/master/Succinct/UIViewController/UIViewController+UITableView.swift
Additionally, the documentation for this also describes the behavior:
/// - Note: This method both selects the row where matching text was found
as well as fires the tableview delegate method "didSelectRowAt:indexPath"
since this does not usually occur from a unit test.
I'd like to follow up by asking in what scenario did you find that Succinct couldn't tap the cell you wanted it to? Is it possible that there's something else causing the cell to not be tapped? Or is it possible that this is related to issue #71 where the cell's isUserInteractionEnabled
is set to false?
In my experience, I've found some aspects of UITableView to be difficult to unit test, so knowing more about the scenario you have encountered will be helpful.
Tests for this portion of the code are located in the UIViewController_UITableViewSpec
file, so there are some example tests there that also might be helpful to reference.
I'm sorry, I think you're right and this wasn't the problem as the Succinct code clearly calls didSelectRowAt.... I'll take a look again tomorrow and see if I can replicate the problem that lead us to calling the delegate method ourselves. Sorry about that, I should have double checked before making an issue!
@rgravina I'm going to close this issue out as it seems that this is functionality that Succinct does support - but if you find otherwise please feel free to re-open (or open a new issue if you find something else).
Thanks! 🙇🏻♂️
Currently Succinct calls this handler when
tapCell
is called.However, if you have implemented the older style table view handler method it is not called