From e3a9f6206f300f8a2bb219c29849e2d03d69666c Mon Sep 17 00:00:00 2001 From: Henrik Fehlauer Date: Sat, 20 Jun 2020 18:00:00 +0000 Subject: [PATCH] Switch to next tab with Shift+T shortcut even if tab is currently closed Often users can remember what the recently opened tab was, so we can switch to and open the next tab immediately, saving one keypress. There is a dedicated shortcut (T) for only opening a tab, after all. While the previous behavior for Shift+T (open tab without switching to next if currently closed) was by intention, user testing found that the new approach might be more desirable. --- js/plugin/Sidebar.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/js/plugin/Sidebar.js b/js/plugin/Sidebar.js index 0199906..36269f2 100644 --- a/js/plugin/Sidebar.js +++ b/js/plugin/Sidebar.js @@ -123,24 +123,24 @@ BR.Sidebar = L.Control.Sidebar.extend({ _keydownListener: function(e) { if (BR.Util.keyboardShortcutsAllowed(e) && e.keyCode === this.options.shortcut.toggleTabs) { if ($('#sidebarTabs > ul > li[class=active]').length) { - // sidebar is currently open - if (e.shiftKey) { - // try to find next tab - var nextTab = $('#sidebarTabs > ul > li[class=active] ~ li:not([hidden]) > a'); - if (!nextTab.length) { - // wrap around to first tab - nextTab = $('#sidebarTabs > ul > li:not([hidden]) > a'); - } - // switch to next or first tab - this.open(nextTab.attr('href').slice(1)); - } else { - // close current tab + // sidebar is currently open, close current tab + if (!e.shiftKey) { this.close(); } } else { // sidebar is currently closed, open recent or default tab this.open(this.recentTab); } + if (e.shiftKey) { + // try to find next tab + var nextTab = $('#sidebarTabs > ul > li[class=active] ~ li:not([hidden]) > a'); + if (!nextTab.length) { + // wrap around to first tab + nextTab = $('#sidebarTabs > ul > li:not([hidden]) > a'); + } + // switch to next or first tab + this.open(nextTab.attr('href').slice(1)); + } } } });