UICollectionView Scroll-to-item with no position behaves differently on iOS 15 vs. all other iOS versions

Originator:kellerbryan19
Number:rdar://FB9940615 Date Originated:2022-03-03
Status:Open Resolved:No
Product:UIKit Product Version:iOS 15 SDK
Classification:Incorrect/Unexpected Behavior Reproducible:
 
On iOS 14 and below, passing `[]` for the `at:` argument of `scrollToItem(_:at:animated:)` results in the target item coming into view at whichever edge is closest. For example, if the item was partially-or-fully out of view past the right edge of the collection view, then it would scroll into view and be aligned along the right edge.

In iOS 15, passing `[]` for the `at:` argument of `scrollToItem(_:at:animated:)` results in the target item always being left aligned, even if its closest edge was the right edge when it was out of view.

The attached playground demonstrates the issue. Is this a bug / regression? A fix / change in behavior for something that was previously considered undefined behavior / API usage? At Airbnb, we depend on this closest-position scroll-to-item behavior in several places. With the behavior changes in iOS 15, we’ll need to reimplement this manually as a workaround unless a future iOS 15 update restores the pre-iOS 15 behavior.

https://drive.google.com/file/d/1xb35qh29Ojljdd6BC_c4gwzhYRqSOR5l/view?usp=sharing

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!