Section removals cause wrong calls to CollectionCellElement
's didDisappear
#16
Labels
bug
Something isn't working
CollectionCellElement
's didDisappear
#16
Describe the bug
When a section is deleted the
didDisappear
call onCollectionElementsProvider
is either not made or is made on the wrongCollectionElementsProvider
.To Reproduce
Delete a section.
Expected behavior
Correct calls to
didDisappear
should be made/should not crash.Environment
Additional context
CollectionCoordinator.collectionView(_:didEndDisplaying:forItemAt:)
uses the state of the hierarchy after the more recent updates have been applied, meaning the removed cell/section is no longer in theSectionProviderMapping
or the localcachedProviders
.For example deleting section 1 with a hierarchy of:
Then remove section 1:
CollectionElementsProvider
didDisappear
on section 2 (even though no cells were removed and it's already empty)Or when section 2 is removed:
guard indexPath.section < sectionProvider.numberOfSections else { return }
I don't have time to look at this right now and I'm not as familiar with the
SectionProviderMapping
as other parts, can you try and fix this @shaps80?A suggested solution is to cache the cells and their sections (e.g.
cellSectionMap: [UICollectionViewCell: Section]
) but I'd like to know if there's a alternative approach since that might lead to more issues down the line?The text was updated successfully, but these errors were encountered: