Merged
Conversation
brynbodayle
approved these changes
Apr 11, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Details
This fixes section moves causing incorrect layouts. This has shockingly been broken since
MagazineLayoutwas created in 2017/18 💀When a section is moved,
UICollectionViewalso generates individual item move updates to go along with the section move. Those eventually turn into some item insertions. If we don't first clear out all existing items in the moved section, then the item insertions will insert all existing items back into the same section, effectively doubling the number of items in the section.This bug thankfully doesn't cause a crash, but it does cause a section to take up more space than it should since it has more items in it. Keep in mind that these are layout models, not data source models, which explains why this doesn't actually cause a data-source-related crash.
AFAIK, this bug was never reported, and we never ran into it at Airbnb - turns out we don't move sections around very often!
Related Issue
N/A
Motivation and Context
Bug fix.
How Has This Been Tested
Example app, unit tests.
Types of changes
Checklist