mirror of
https://github.com/Instagram/IGListKit
synced 2026-05-23 09:18:29 +00:00
Fix deselection from stack collection context offset
Summary: Offset should be relative. Fixes #279 - [x] All tests pass. Demo project builds and runs. - [x] I added tests, an experiment, or detailed why my change isn't tested. - [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md) Closes https://github.com/Instagram/IGListKit/pull/295 Differential Revision: D4290143 Pulled By: rnystrom fbshipit-source-id: 8d6dccb821b12700d0d7e8704006ef5371396dfd
This commit is contained in:
parent
ea98e1b41c
commit
e66bd85e32
3 changed files with 20 additions and 2 deletions
|
|
@ -113,6 +113,8 @@ You can find a [migration guide here](https://instagram.github.io/IGListKit/migr
|
|||
|
||||
- Fixed a bug where `IGListStackSectionController` passed the wrong section controller for will-drag scroll events. [Ryan Nystrom](https://github.com/rnystrom) [(#286)](https://github.com/Instagram/IGListKit/pull/286)
|
||||
|
||||
- Fixed a crash when deselecting a cell through a child section controller in an `IGListStackSectionController`. [Ryan Nystrom](https://github.com/rnystrom) [(#295)](https://github.com/Instagram/IGListKit/pull/295)
|
||||
|
||||
1.0.0
|
||||
-----
|
||||
|
||||
|
|
|
|||
|
|
@ -162,8 +162,8 @@
|
|||
}
|
||||
|
||||
- (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];
|
||||
const NSUInteger offsetIndex = [self relativeIndexForSectionController:sectionController fromLocalIndex:index];
|
||||
[self.collectionContext deselectItemAtIndex:offsetIndex sectionController:self animated:animated];
|
||||
}
|
||||
|
||||
- (NSInteger)sectionForSectionController:(IGListSectionController<IGListSectionType> *)sectionController {
|
||||
|
|
|
|||
|
|
@ -686,4 +686,20 @@ static const CGRect kStackTestFrame = (CGRect){{0.0, 0.0}, {100.0, 100.0}};
|
|||
XCTAssertEqual(self.collectionView.contentOffset.y, 170);
|
||||
}
|
||||
|
||||
- (void)test_whenDeselectingChildSectionControllerIndex_thatCorrectCellDeselected {
|
||||
[self setupWithObjects:@[
|
||||
[[IGTestObject alloc] initWithKey:@0 value:@[@1, @2, @3]],
|
||||
[[IGTestObject alloc] initWithKey:@1 value:@[@1, @1]]
|
||||
]];
|
||||
|
||||
NSIndexPath *path = [NSIndexPath indexPathForItem:1 inSection:1];
|
||||
[self.collectionView selectItemAtIndexPath:path animated:NO scrollPosition:UICollectionViewScrollPositionTop];
|
||||
XCTAssertTrue([[self.collectionView cellForItemAtIndexPath:path] isSelected]);
|
||||
|
||||
IGListStackedSectionController *stack = [self.adapter sectionControllerForObject:self.dataSource.objects.lastObject];
|
||||
IGListSectionController<IGListSectionType> *section = stack.sectionControllers.lastObject;
|
||||
[section.collectionContext deselectItemAtIndex:0 sectionController:section animated:NO];
|
||||
XCTAssertFalse([[self.collectionView cellForItemAtIndexPath:path] isSelected]);
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
Loading…
Reference in a new issue