Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CollectionView] Guard against a UIKit crash caused by attempting to scroll to an item that no longer exists #142

Merged
merged 1 commit into from
Apr 19, 2023

Conversation

erichoracek
Copy link
Collaborator

Change summary

Calling scrollToItem(…) with in invalid index path raises an exception:

NSInternalInconsistencyException: Attempted to scroll the collection view to an out-of-bounds item

We must guard against this to check to ensure that this never happens, as we call this method repeatedly and the items/section may change out from under us.

How was it tested?

How did you verify that this change accomplished what you expected? Add more detail as needed.

  • Wrote automated tests
  • Built and ran on the iOS simulator, verified crash reproduced without this check and didn't with this check
  • Built and ran on a device

Pull request checklist

All items in this checklist must be completed before a pull request will be reviewed.

  • Risky changes have been put behind a feature flag, e.g. CollectionViewConfiguration
  • Added a CHANGELOG.md entry in the "Unreleased" section for any library changes

…scroll to an item that no longer exists

Calling `scrollToItem(…)` with in invalid index path raises an exception:

> NSInternalInconsistencyException: Attempted to scroll the collection view to an out-of-bounds item

We must guard against this to check to ensure that this never happens, as we call this method repeatedly and the items/section may change out from under us.
@erichoracek erichoracek merged commit 9f9c93c into master Apr 19, 2023
@erichoracek erichoracek deleted the eh--fix-crash branch April 19, 2023 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants