Use performPrimaryActionForItemAt so that tapping the already-selected feed still navigates. Fixes #4691.

This commit is contained in:
Brent Simmons committed 2026-07-27 09:07:47 -07:00
1 parent 37f70e1324
commit a080925cb9
2 files changed
+22 -19

No files matched your search

@@ -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
// <https://github.com/Ranchero-Software/NetNewsWire/issues/5043>
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
/*
+4
View File
@@ -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
}