From dae376500bde31ac86860ef65583415a4b6c5bcb Mon Sep 17 00:00:00 2001 From: dnahol Date: Thu, 10 Oct 2019 10:11:04 -0700 Subject: [PATCH] added right and left arrow shortcuts for container submenu tabs change focus to whole panel element after right arrow press, allows navigation without pressing tab --- src/js/popup.js | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/js/popup.js b/src/js/popup.js index 80986a2..01e792d 100644 --- a/src/js/popup.js +++ b/src/js/popup.js @@ -543,6 +543,7 @@ Logic.registerPanel(P_CONTAINERS_LIST, { previousElement.focus(); } } + switch (e.keyCode) { case 40: next(); @@ -550,6 +551,26 @@ Logic.registerPanel(P_CONTAINERS_LIST, { case 38: previous(); break; + case 39: + { + const showTabs = element.parentNode.querySelector(".show-tabs"); + if(showTabs) { + showTabs.click(); + } + const panel = document.querySelector("html"); + if(panel) { + panel.focus(); + } + break; + } + case 37: + { + const hideTabs = element.parentNode.querySelector(".panel-back-arrow"); + if(hideTabs) { + hideTabs.click(); + } + break; + } default: if ((e.keyCode >= 49 && e.keyCode <= 57) && Logic._currentPanel === "containersList") { @@ -747,7 +768,7 @@ Logic.registerPanel(P_CONTAINER_INFO, { return; } else if (numTabs === 1) { Logic._disableMoveTabs("Cannot move a tab from a single-tab window."); - return; + return; } Logic.addEnterHandler(moveTabsEl, async () => { await browser.runtime.sendMessage({ @@ -808,7 +829,7 @@ Logic.registerPanel(P_CONTAINER_INFO, {
${tab.title}
`; tr.querySelector("td").appendChild(Utils.createFavIconElement(tab.favIconUrl)); document.getElementById("container-info-table").appendChild(fragment); - + // On click, we activate this tab. But only if this tab is active. if (!tab.hiddenState) { const closeImage = document.createElement("img"); @@ -842,7 +863,7 @@ Logic.registerPanel(P_CONTAINER_INFO, { }); } } - } + } }, }); @@ -1154,4 +1175,4 @@ window.addEventListener("resize", function () { root.style.setProperty("--overflow-size", difference + "px"); root.style.setProperty("--icon-fit", "12"); } -}); \ No newline at end of file +});