From a080925cb9f0f7c778e4dc4ac1b02c62c35a66a7 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Mon, 27 Jul 2026 09:07:47 -0700 Subject: [PATCH] Use performPrimaryActionForItemAt so that tapping the already-selected feed still navigates. Fixes #4691. --- .../MainFeedCollectionViewController.swift | 37 +++++++++---------- iOS/SceneCoordinator.swift | 4 ++ 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/iOS/MainFeed/MainFeedCollectionViewController.swift b/iOS/MainFeed/MainFeedCollectionViewController.swift index c04c1d83e..d1358b1fe 100644 --- a/iOS/MainFeed/MainFeedCollectionViewController.swift +++ b/iOS/MainFeed/MainFeedCollectionViewController.swift @@ -148,26 +148,13 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab self.isAnimating = false } - // Pro Max may have split view in landscape — give the device some - // time to change its size class and then decide to deselect - // - DispatchQueue.main.asyncAfter(deadline: .now() + 0.1, execute: { - // If the iPhone is in portrait, deselect. - if UIDevice.current.orientation.isPortrait { - if self.collectionView.indexPathsForSelectedItems != nil { - self.coordinator.selectSidebarItem(indexPath: nil, animations: [.select]) - } - return + // Rotating a Pro Max to landscape expands the split view — wait for the transition to settle. #5043 + DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { + // Deselect only when the feeds list is full screen. #4691 + if self.coordinator.isRootSplitCollapsed, self.collectionView.indexPathsForSelectedItems?.first != nil { + self.coordinator.selectSidebarItem(indexPath: nil, animations: [.select]) } - - // If the iPhone is in landscape, and the horizontal - // size class is compact, deselect. - if self.view.window?.traitCollection.horizontalSizeClass == .compact { - if self.collectionView.indexPathsForSelectedItems != nil { self.coordinator.selectSidebarItem(indexPath: nil, animations: [.select]) - } - return - } - }) + } } func registerForNotifications() { @@ -405,9 +392,21 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { becomeFirstResponder() + } + + // Fires on every tap — even on the already-selected feed, which doesn't get didSelectItemAt. + override func collectionView(_ collectionView: UICollectionView, performPrimaryActionForItemAt indexPath: IndexPath) { + becomeFirstResponder() coordinator.selectSidebarItem(indexPath: indexPath, animations: [.navigation, .select, .scroll]) } + override func collectionView(_ collectionView: UICollectionView, canPerformPrimaryActionForItemAt indexPath: IndexPath) -> Bool { + if traitCollection.userInterfaceIdiom == .pad { + return true + } + return !isAnimating + } + // MARK: UICollectionViewDelegate /* diff --git a/iOS/SceneCoordinator.swift b/iOS/SceneCoordinator.swift index f0c8405d8..a3d1b6b70 100644 --- a/iOS/SceneCoordinator.swift +++ b/iOS/SceneCoordinator.swift @@ -953,6 +953,10 @@ struct SidebarItemNode: Hashable, Sendable { tappedFeed = nodeFor(indexPath)?.representedObject as AnyObject? } guard tappedFeed !== timelineFeed as AnyObject? else { + // Same feed — just make sure the timeline is showing. + if indexPath != nil { + rootSplitViewController.show(.supplementary) + } completion?() return }