From 30dc1cc655ab60c789f9be1ff4abfd0608791140 Mon Sep 17 00:00:00 2001 From: Kendall Werts Date: Fri, 28 Feb 2020 12:14:48 -0600 Subject: [PATCH] Removed options from new container menu. Tweaked new container menu to remove dupes from opening it twice. Added focus highlighting for keyboard navigation --- src/css/popup.css | 3 ++- src/js/background/assignManager.js | 1 - src/js/popup.js | 17 ++++++++--------- src/js/utils.js | 16 +++++++--------- src/popup.html | 14 ++++++++------ 5 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/css/popup.css b/src/css/popup.css index eaf94dd..293a970 100644 --- a/src/css/popup.css +++ b/src/css/popup.css @@ -680,7 +680,8 @@ h3.title { font-style: italic; } -.hover-highlight:hover { +.hover-highlight:hover, +.hover-highlight:focus { background: var(--highlight-blue); color: #fff; } diff --git a/src/js/background/assignManager.js b/src/js/background/assignManager.js index dad3db2..deee22a 100644 --- a/src/js/background/assignManager.js +++ b/src/js/background/assignManager.js @@ -530,7 +530,6 @@ window.assignManager = { async _setOrRemoveAssignment(tabId, pageUrl, userContextId, remove) { let actionName; - // https://github.com/mozilla/testpilot-containers/issues/626 // Context menu has stored context IDs as strings, so we need to coerce // the value to a string for accurate checking diff --git a/src/js/popup.js b/src/js/popup.js index 7f9d940..e4ec055 100644 --- a/src/js/popup.js +++ b/src/js/popup.js @@ -1215,6 +1215,13 @@ Logic.registerPanel(P_CONTAINER_EDIT, { this._editForm.addEventListener("submit", () => { this._submitForm(); }); + Utils.addEnterHandler(document.querySelector("#create-container-cancel-link"), () => { + Logic.showPreviousPanel(); + }); + + Utils.addEnterHandler(document.querySelector("#create-container-ok-link"), () => { + this._submitForm(); + }); }, async _submitForm() { @@ -1275,18 +1282,10 @@ Logic.registerPanel(P_CONTAINER_EDIT, { // Populating the panel: name and icon document.getElementById("container-edit-title").textContent = identity.name; - const userContextId = Logic.currentUserContextId(); document.querySelector("#edit-container-panel .panel-footer").hidden = !!userContextId; document.querySelector("#edit-container-panel .delete-container").hidden = !userContextId; - - Utils.addEnterHandler(document.querySelector("#create-container-cancel-link"), () => { - Logic.showPreviousPanel(); - }); - - Utils.addEnterHandler(document.querySelector("#create-container-ok-link"), () => { - this._submitForm(); - }); + document.querySelector("#edit-container-options").hidden = !userContextId; Utils.addEnterHandler(document.querySelector("#manage-assigned-sites-list"), () => { Logic.showPanel(P_CONTAINER_ASSIGNMENTS, identity); diff --git a/src/js/utils.js b/src/js/utils.js index 68c821b..97bf8e3 100644 --- a/src/js/utils.js +++ b/src/js/utils.js @@ -102,7 +102,7 @@ const Utils = { }, async alwaysOpenInContainer(identity) { - let currentTab = await this.currentTab(); + const currentTab = await this.currentTab(); const assignedUserContextId = this.userContextId(identity.cookieStoreId); if (currentTab.cookieStoreId !== identity.cookieStoreId) { return await browser.runtime.sendMessage({ @@ -113,15 +113,13 @@ const Utils = { tabIndex: currentTab.index +1, active:currentTab.active }); - } else { - currentTab = await this.currentTab(); - Utils.setOrRemoveAssignment( - currentTab.id, - currentTab.url, - assignedUserContextId, - false - ); } + await Utils.setOrRemoveAssignment( + currentTab.id, + currentTab.url, + assignedUserContextId, + false + ); } }; diff --git a/src/popup.html b/src/popup.html index 4f660cf..cf39c1d 100644 --- a/src/popup.html +++ b/src/popup.html @@ -299,12 +299,14 @@ Icon -
Options
-
- - -
-
Manage Site List... +
+
Options
+
+ + +
+
Manage Site List... +