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
This commit is contained in:
dnahol 2019-10-10 10:11:04 -07:00
parent a4c578adde
commit dae376500b

View file

@ -543,6 +543,7 @@ Logic.registerPanel(P_CONTAINERS_LIST, {
previousElement.focus(); previousElement.focus();
} }
} }
switch (e.keyCode) { switch (e.keyCode) {
case 40: case 40:
next(); next();
@ -550,6 +551,26 @@ Logic.registerPanel(P_CONTAINERS_LIST, {
case 38: case 38:
previous(); previous();
break; 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: default:
if ((e.keyCode >= 49 && e.keyCode <= 57) && if ((e.keyCode >= 49 && e.keyCode <= 57) &&
Logic._currentPanel === "containersList") { Logic._currentPanel === "containersList") {
@ -747,7 +768,7 @@ Logic.registerPanel(P_CONTAINER_INFO, {
return; return;
} else if (numTabs === 1) { } else if (numTabs === 1) {
Logic._disableMoveTabs("Cannot move a tab from a single-tab window."); Logic._disableMoveTabs("Cannot move a tab from a single-tab window.");
return; return;
} }
Logic.addEnterHandler(moveTabsEl, async () => { Logic.addEnterHandler(moveTabsEl, async () => {
await browser.runtime.sendMessage({ await browser.runtime.sendMessage({
@ -808,7 +829,7 @@ Logic.registerPanel(P_CONTAINER_INFO, {
<td class="container-info-tab-title truncate-text" title="${tab.url}" ><div class="container-tab-title">${tab.title}</div></td>`; <td class="container-info-tab-title truncate-text" title="${tab.url}" ><div class="container-tab-title">${tab.title}</div></td>`;
tr.querySelector("td").appendChild(Utils.createFavIconElement(tab.favIconUrl)); tr.querySelector("td").appendChild(Utils.createFavIconElement(tab.favIconUrl));
document.getElementById("container-info-table").appendChild(fragment); document.getElementById("container-info-table").appendChild(fragment);
// On click, we activate this tab. But only if this tab is active. // On click, we activate this tab. But only if this tab is active.
if (!tab.hiddenState) { if (!tab.hiddenState) {
const closeImage = document.createElement("img"); 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("--overflow-size", difference + "px");
root.style.setProperty("--icon-fit", "12"); root.style.setProperty("--icon-fit", "12");
} }
}); });