Describe the bug
When a section is deleted the didDisappear call on CollectionElementsProvider is either not made or is made on the wrong CollectionElementsProvider.
To Reproduce
Delete a section.
Expected behavior
Correct calls to didDisappear should be made/should not crash.
Environment
- OS Version: Any iOS
- Library Version: 1.05
- Device: Any
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 the SectionProviderMapping or the local cachedProviders.
For example deleting section 1 with a hierarchy of:
- section 0
- section 1
- section 2
Then remove section 1:
- Crashes when the cell is cast to the wrong type
- This happens when section 1 and have different cell types
- Calls the wrong
CollectionElementsProvider
- This happens when section 1 and have the same cell types
- This would call
didDisappear on section 2 (even though no cells were removed and it's already empty)
Or when section 2 is removed:
- Makes no call at all
- This happens because of
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?
Describe the bug
When a section is deleted the
didDisappearcall onCollectionElementsProvideris either not made or is made on the wrongCollectionElementsProvider.To Reproduce
Delete a section.
Expected behavior
Correct calls to
didDisappearshould 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 theSectionProviderMappingor the localcachedProviders.For example deleting section 1 with a hierarchy of:
Then remove section 1:
CollectionElementsProviderdidDisappearon 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
SectionProviderMappingas 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?