File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
Sources/ComposedUI/CollectionView Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -217,6 +217,14 @@ extension CollectionCoordinator: SectionProviderMappingDelegate {
217
217
public func mappingWillBeginUpdating( _ mapping: SectionProviderMapping ) {
218
218
reset ( )
219
219
defersUpdate = true
220
+
221
+ // This is called here to ensure that the collection view's internal state is in-sync with the state of the
222
+ // data in hierarchy of sections. If this is not done it can cause various crashes when `performBatchUpdates` is called
223
+ // due to the collection view requesting data for sections that no longer exist, or crashes because the collection view is
224
+ // told to delete/insert from/into sections that it does not yet think exist.
225
+ //
226
+ // For more information on this see https://github.com/composed-swift/ComposedUI/pull/14
227
+ collectionView. layoutIfNeeded ( )
220
228
}
221
229
222
230
public func mappingDidEndUpdating( _ mapping: SectionProviderMapping ) {
You can’t perform that action at this time.
0 commit comments