Instagram / IGListKit

A data-driven UICollectionView framework for building fast and flexible lists.
https://instagram.github.io/IGListKit/
MIT License
12.87k stars 1.54k forks source link

IGListStackedSectionController deselectItemAtIndex:sectionController:animated bug #279

Closed jeffbailey closed 7 years ago

jeffbailey commented 7 years ago

New issue checklist

General information

The current implementation is this:

- (void)deselectItemAtIndex:(NSInteger)index sectionController:(IGListSectionController<IGListSectionType> *)sectionController animated:(BOOL)animated {
    const NSUInteger localIndex = [self localIndexForSectionController:sectionController index:index];
    [self.collectionContext deselectItemAtIndex:localIndex sectionController:self animated:animated];
}

But I believe the correct implementation is:

- (void)deselectItemAtIndex:(NSInteger)index sectionController:(IGListSectionController<IGListSectionType> *)sectionController animated:(BOOL)animated {    
    const NSUInteger relativeIndex = [self relativeIndexForSectionController:sectionController fromLocalIndex:index];
    [self.collectionContext deselectItemAtIndex:relativeIndex sectionController:self animated:animated];
}

The index being passed to this method is already a local index, so it needs to be converted to an index relative to the Stacked Section Controller.

rnystrom commented 7 years ago

Yikes, yup! Spot on. Definitely a bug w/ stacked section controller.

jeffbailey commented 7 years ago

Great. IGListKit is brilliant BTW. Thanks for making it open source.

rnystrom commented 7 years ago

@jeffbailey that means the world to me