RxSwiftCommunity / RxDataSources

UITableView and UICollectionView Data Sources for RxSwift (sections, animated updates, editing ...)
MIT License
3.09k stars 494 forks source link

TableViewSectionedDataSource default parameters don't reflect iOS default behavior #382

Closed saschagordner closed 3 years ago

saschagordner commented 3 years ago

I've stumbled across https://github.com/RxSwiftCommunity/RxDataSources/issues/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: https://github.com/RxSwiftCommunity/RxDataSources/blob/e4ffaafe76f21f149c90ea5fac8255d9778beff3/Sources/RxDataSources/TableViewSectionedDataSource.swift#L40-L41

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.