Skip to content

Commit

Permalink
Enable using the invalidateLayout method in IGListCollectionViewLayout
Browse files Browse the repository at this point in the history
Summary:
I noticed some strange behaviour in a collection view I was testing that was using `IGListCollectionView` and `IGListCollectionViewLayout`. Even if I called `invalidateLayout` on it, the cells wouldn't resize and would sometimes end up overflowing outside the collection view's bound.

I eventually managed to trace this back to `IGListCollectionViewLayout` that uses a `_minimumInvalidatedSection` flag to track when list content has changed before it starts calling the sizing logic of each section controller. While `invalidateLayoutWithContext:(IGListCollectionViewLayoutInvalidationContext *)context` was correctly setting this flag, `invalidateLayout` wasn't subclassed, and so this call was basically always falling through.

This diff configures `invalidateLayout` to set this flag, so when this method is called, it will correctly perform a new cell sizing pass.

Reviewed By: DimaVartanian

Differential Revision: D47787723

fbshipit-source-id: 724d76ba3e7b5c32b60e7c76347a129c30f0b502
  • Loading branch information
TimOliver authored and facebook-github-bot committed Jul 27, 2023
1 parent e965f28 commit ffd51e6
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Source/IGListKit/IGListCollectionViewLayout.mm
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,11 @@ - (CGSize)collectionViewContentSize {
}
}

- (void)invalidateLayout {
_minimumInvalidatedSection = 0;
[super invalidateLayout];
}

- (void)invalidateLayoutWithContext:(IGListCollectionViewLayoutInvalidationContext *)context {
BOOL hasInvalidatedItemIndexPaths = NO;
if ([context respondsToSelector:@selector(invalidatedItemIndexPaths)]) {
Expand Down

0 comments on commit ffd51e6

Please # to comment.