RxSwiftCommunity / RxDataSources

UITableView and UICollectionView Data Sources for RxSwift (sections, animated updates, editing ...)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TableViewSectionedDataSource default parameters don't reflect iOS default behavior

forceunwrap opened this issue · comments

I've stumbled across #359, where the table swipe actions introduced with iOS 11 don't work, unless you implement dataSource.canEditRowAtIndexPath = { datasource, index -> Bool in return true }.

This issue arises from the default values set in TableViewSectionedDataSource:

canEditRowAtIndexPath: @escaping CanEditRowAtIndexPath = { _, _ in false },
canMoveRowAtIndexPath: @escaping CanMoveRowAtIndexPath = { _, _ in false },

Apple Docs state:
tableView(_:canEditRowAt:)

... If this method is not implemented, all rows are assumed to be editable. ...

tableView(_:canMoveRowAt:)

...By default, the reordering control is shown if the data source implements the tableView(_:moveRowAt:to:) method.

The current default values require a developer using tableView(_:leadingSwipeActionsConfigurationForRowAt:)/ tableView(_:trailingSwipeActionsConfigurationForRowAt:) to explicitly return true for canEditRowAtIndexPath - which is not necessary when doing it without RxDataSources.
Therefor, both closures should return true to mimic iOS' default behavior.