From 31f3487d7aedc4c87a0f13bde75d342505091c33 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Tue, 28 Apr 2020 17:16:34 -0500 Subject: [PATCH] Reset focus when returning to the app from another app or the safari view controller. Issue #1963 --- iOS/RootSplitViewController.swift | 4 ++++ iOS/SceneCoordinator.swift | 8 ++++++++ iOS/SceneDelegate.swift | 3 ++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/iOS/RootSplitViewController.swift b/iOS/RootSplitViewController.swift index 4a95fee0e..852c863d1 100644 --- a/iOS/RootSplitViewController.swift +++ b/iOS/RootSplitViewController.swift @@ -21,6 +21,10 @@ class RootSplitViewController: UISplitViewController { return .slide } + override func viewDidAppear(_ animated: Bool) { + coordinator.resetFocus() + } + override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { self.coordinator.configurePanelMode(for: size) super.viewWillTransition(to: size, with: coordinator) diff --git a/iOS/SceneCoordinator.swift b/iOS/SceneCoordinator.swift index 3773f99b6..25b732781 100644 --- a/iOS/SceneCoordinator.swift +++ b/iOS/SceneCoordinator.swift @@ -405,6 +405,14 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { wasRootSplitViewControllerCollapsed = rootSplitViewController.isCollapsed } + func resetFocus() { + if currentArticle != nil { + masterTimelineViewController?.focus() + } else { + masterFeedViewController?.focus() + } + } + func selectFirstUnreadInAllUnread() { markExpanded(SmartFeedsController.shared) self.ensureFeedIsAvailableToSelect(SmartFeedsController.shared.unreadFeed) { diff --git a/iOS/SceneDelegate.swift b/iOS/SceneDelegate.swift index f95678c83..0a4ffdf80 100644 --- a/iOS/SceneDelegate.swift +++ b/iOS/SceneDelegate.swift @@ -66,7 +66,8 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { func sceneWillEnterForeground(_ scene: UIScene) { appDelegate.resumeDatabaseProcessingIfNecessary() appDelegate.prepareAccountsForForeground() - self.coordinator.configurePanelMode(for: window!.frame.size) + coordinator.configurePanelMode(for: window!.frame.size) + coordinator.resetFocus() } func stateRestorationActivity(for scene: UIScene) -> NSUserActivity? {