From ffd51e6235c761b14c52ac657c69dd52ee7b321f Mon Sep 17 00:00:00 2001 From: Tim Oliver Date: Wed, 26 Jul 2023 20:35:00 -0700 Subject: [PATCH] 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 --- Source/IGListKit/IGListCollectionViewLayout.mm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Source/IGListKit/IGListCollectionViewLayout.mm b/Source/IGListKit/IGListCollectionViewLayout.mm index 6678b8350..534f60025 100644 --- a/Source/IGListKit/IGListCollectionViewLayout.mm +++ b/Source/IGListKit/IGListCollectionViewLayout.mm @@ -376,6 +376,11 @@ - (CGSize)collectionViewContentSize { } } +- (void)invalidateLayout { + _minimumInvalidatedSection = 0; + [super invalidateLayout]; +} + - (void)invalidateLayoutWithContext:(IGListCollectionViewLayoutInvalidationContext *)context { BOOL hasInvalidatedItemIndexPaths = NO; if ([context respondsToSelector:@selector(invalidatedItemIndexPaths)]) {