Skip to content

Commit 8f0d651

Browse files
committed
Potential fix for invalidation crashes
As mentioned in #13 and #8 there are some scenarios where the collection view’s data is out-of-sync with the data in composed. As mentioned in #13 calling `layoutIfNeeded` can trigger the data to be in sync again. In this I have added it to `mappingWillBeginUpdating(_:)` which _appears_ to solve the problem. It might be needed in `replace(sectionProvider:)` (because `reloadData` is called) and/or `mappingDidInvalidate(_:)` (for the same reason) but I’m still investigating.
1 parent 8ee5b11 commit 8f0d651

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

Sources/ComposedUI/CollectionView/CollectionCoordinator.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ extension CollectionCoordinator: SectionProviderMappingDelegate {
217217
public func mappingWillBeginUpdating(_ mapping: SectionProviderMapping) {
218218
reset()
219219
defersUpdate = true
220+
collectionView.layoutIfNeeded()
220221
}
221222

222223
public func mappingDidEndUpdating(_ mapping: SectionProviderMapping) {

0 commit comments

Comments
 (0)