Enable using the invalidateLayout method in IGListCollectionViewLayout

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
This commit is contained in:
Tim Oliver 2023-07-26 20:35:00 -07:00 committed by Facebook GitHub Bot
parent e965f28515
commit ffd51e6235

View file

@ -376,6 +376,11 @@ static void adjustZIndexForAttributes(UICollectionViewLayoutAttributes *attribut
}
}
- (void)invalidateLayout {
_minimumInvalidatedSection = 0;
[super invalidateLayout];
}
- (void)invalidateLayoutWithContext:(IGListCollectionViewLayoutInvalidationContext *)context {
BOOL hasInvalidatedItemIndexPaths = NO;
if ([context respondsToSelector:@selector(invalidatedItemIndexPaths)]) {