From e9e8b46a48ec2287604a8a42b557d2b19b9b331f Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Mon, 27 Jul 2026 10:04:33 -0700 Subject: [PATCH] =?UTF-8?q?Scroll=20the=20selected=20item=20into=20view=20?= =?UTF-8?q?when=20it's=20only=20partially=20visible=20=E2=80=94=20cells=20?= =?UTF-8?q?under=20the=20column=20title=20were=20counted=20as=20visible.?= =?UTF-8?q?=20Fixes=20#5107.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/RSCore/UIKit/UICollectionView+RSCore.swift | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Modules/RSCore/Sources/RSCore/UIKit/UICollectionView+RSCore.swift b/Modules/RSCore/Sources/RSCore/UIKit/UICollectionView+RSCore.swift index 8ccddeefe..2498b3b99 100644 --- a/Modules/RSCore/Sources/RSCore/UIKit/UICollectionView+RSCore.swift +++ b/Modules/RSCore/Sources/RSCore/UIKit/UICollectionView+RSCore.swift @@ -24,9 +24,14 @@ extension UICollectionView { selectItem(at: indexPath, animated: true, scrollPosition: []) - if !indexPathsForVisibleItems.contains(indexPath) { - scrollToItem(at: indexPath, at: .centeredVertically, animated: true) + // indexPathsForVisibleItems includes cells hidden under the bars — + // check the unobscured region instead. + // + let unobscuredBounds = bounds.inset(by: adjustedContentInset) + if let itemFrame = layoutAttributesForItem(at: indexPath)?.frame, unobscuredBounds.contains(itemFrame) { + return } + scrollToItem(at: indexPath, at: .centeredVertically, animated: true) } public func middleVisibleRow() -> IndexPath? {