From 118ce73c08e2ee66b84eba87f12799d8b0c125aa Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sat, 14 Mar 2020 14:36:18 -0500 Subject: [PATCH] Change focus when the sidebar is shown or hidden. Issue #1004 --- Mac/Base.lproj/Main.storyboard | 2 +- Mac/MainWindow/MainWindowController.swift | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Mac/Base.lproj/Main.storyboard b/Mac/Base.lproj/Main.storyboard index dbbb3e8d3..63ebe5718 100644 --- a/Mac/Base.lproj/Main.storyboard +++ b/Mac/Base.lproj/Main.storyboard @@ -384,7 +384,7 @@ - + diff --git a/Mac/MainWindow/MainWindowController.swift b/Mac/MainWindow/MainWindowController.swift index 55a17e6b0..191aa3aa0 100644 --- a/Mac/MainWindow/MainWindowController.swift +++ b/Mac/MainWindow/MainWindowController.swift @@ -226,7 +226,7 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations { return validateToggleReadArticles(item) } - if item.action == #selector(toggleSidebar(_:)) { + if item.action == #selector(toggleTheSidebar(_:)) { guard let splitViewItem = sidebarSplitViewItem else { return false } @@ -360,8 +360,14 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations { nextUnread(sender) } - @IBAction func toggleSidebar(_ sender: Any?) { + @IBAction func toggleTheSidebar(_ sender: Any?) { splitViewController!.toggleSidebar(sender) + guard let splitViewItem = sidebarSplitViewItem else { return } + if splitViewItem.isCollapsed { + currentTimelineViewController?.focus() + } else { + sidebarViewController?.focus() + } } @IBAction func markAboveArticlesAsRead(_ sender: Any?) {