diff --git a/webextension/css/popup.css b/webextension/css/popup.css index dd460d3..607563c 100644 --- a/webextension/css/popup.css +++ b/webextension/css/popup.css @@ -130,11 +130,13 @@ table { color: white; } -.button.primary:hover { +.button.primary:hover, +.button.primary:focus { background-color: #0675d3; } -.button.secondary:hover { +.button.secondary:hover, +.button.secondary:focus { background-color: rgba(0, 0, 0, 0.05); } @@ -198,7 +200,8 @@ table { justify-content: center; } -.panel-back-arrow:hover { +.panel-back-arrow:hover, +.panel-back-arrow:focus { background: #dedede; } @@ -249,7 +252,8 @@ table { transition: background-color 75ms; } -.onboarding-button:hover { +.onboarding-button:hover, +.onboarding-button:active { background-color: #0675d3; } @@ -264,12 +268,14 @@ manage things like container crud */ } .pop-button:hover, +.pop-button:focus, +.panel-footer-secondary:focus, .panel-footer-secondary:hover { background-color: rgba(0, 0, 0, 0.05); } -.pop-button:active, -.panel-footer-secondary:active { +.pop-button:focus, +.panel-footer-secondary:focus { background-color: rgba(0, 0, 0, 0.08); } @@ -350,7 +356,8 @@ span ~ .panel-header-text { transition: background-color 75ms; } -.clickable.userContext-wrapper:hover { +.container-panel-row:hover .clickable.userContext-wrapper, +.container-panel-row:focus .clickable.userContext-wrapper { background: #f2f2f2; } @@ -360,7 +367,6 @@ span ~ .panel-header-text { } /* .userContext-icon is used natively, Bug 1333811 was raised to fix */ -.userContext-icon, .usercontext-icon { background-image: var(--identity-icon); background-position: center center; @@ -372,8 +378,8 @@ span ~ .panel-header-text { flex: 0 0 48px; } -.clickable:hover .userContext-icon, -.clickable:hover .usercontext-icon { +.container-panel-row:hover .clickable .usercontext-icon, +.container-panel-row:focus .clickable .usercontext-icon { background-image: url('/img/container-newtab.svg'); fill: 'gray'; filter: url('/img/filters.svg#fill'); @@ -482,7 +488,8 @@ span ~ .panel-header-text { cursor: pointer; } -.clickable:hover { +.clickable:hover, +.clickable:focus { background-color: #ebebeb; } diff --git a/webextension/js/popup.js b/webextension/js/popup.js index b1289ae..c1d14a3 100644 --- a/webextension/js/popup.js +++ b/webextension/js/popup.js @@ -107,6 +107,15 @@ const Logic = { browser.storage.local.set({browserActionBadgesClicked: storage.browserActionBadgesClicked}); }, + addEnterHandler(element, handler) { + element.addEventListener("click", handler); + element.addEventListener("keydown", (e) => { + if (e.keyCode === 13) { + handler(e); + } + }); + }, + refreshIdentities() { return browser.runtime.sendMessage({ method: "queryIdentities" @@ -214,7 +223,7 @@ Logic.registerPanel(P_ONBOARDING_1, { // This method is called when the object is registered. initialize() { // Let's move to the next panel. - document.querySelector("#onboarding-start-button").addEventListener("click", () => { + Logic.addEnterHandler(document.querySelector("#onboarding-start-button"), () => { localStorage.setItem("onboarded1", true); Logic.showPanel(P_ONBOARDING_2); }); @@ -235,7 +244,7 @@ Logic.registerPanel(P_ONBOARDING_2, { // This method is called when the object is registered. initialize() { // Let's move to the containers list panel. - document.querySelector("#onboarding-next-button").addEventListener("click", () => { + Logic.addEnterHandler(document.querySelector("#onboarding-next-button"), () => { localStorage.setItem("onboarded2", true); Logic.showPanel(P_ONBOARDING_3); }); @@ -256,7 +265,7 @@ Logic.registerPanel(P_ONBOARDING_3, { // This method is called when the object is registered. initialize() { // Let's move to the containers list panel. - document.querySelector("#onboarding-almost-done-button").addEventListener("click", () => { + Logic.addEnterHandler(document.querySelector("#onboarding-almost-done-button"), () => { localStorage.setItem("onboarded3", true); Logic.showPanel(P_ONBOARDING_4); }); @@ -297,18 +306,18 @@ Logic.registerPanel(P_CONTAINERS_LIST, { // This method is called when the object is registered. initialize() { - document.querySelector("#container-add-link").addEventListener("click", () => { + Logic.addEnterHandler(document.querySelector("#container-add-link"), () => { Logic.showPanel(P_CONTAINER_EDIT, { name: Logic.generateIdentityName() }); }); - document.querySelector("#edit-containers-link").addEventListener("click", () => { + Logic.addEnterHandler(document.querySelector("#edit-containers-link"), () => { Logic.sendTelemetryPayload({ event: "edit-containers" }); Logic.showPanel(P_CONTAINERS_EDIT); }); - document.querySelector("#sort-containers-link").addEventListener("click", () => { + Logic.addEnterHandler(document.querySelector("#sort-containers-link"), () => { browser.runtime.sendMessage({ method: "sortTabs" }).then(() => { @@ -317,6 +326,30 @@ Logic.registerPanel(P_CONTAINERS_LIST, { window.close(); }); }); + + document.addEventListener("keydown", (e) => { + const element = document.activeElement; + function next() { + const nextElement = element.nextElementSibling; + if (nextElement) { + nextElement.focus(); + } + } + function previous() { + const previousElement = element.previousElementSibling; + if (previousElement) { + previousElement.focus(); + } + } + switch (e.keyCode) { + case 40: + next(); + break; + case 38: + previous(); + break; + } + }); }, // This method is called when the panel is shown. @@ -330,11 +363,14 @@ Logic.registerPanel(P_CONTAINERS_LIST, { const manage = document.createElement("td"); tr.classList.add("container-panel-row"); + + tr.setAttribute("tabindex", "0"); + context.classList.add("userContext-wrapper", "open-newtab", "clickable"); manage.classList.add("show-tabs", "pop-button"); context.innerHTML = escaped`