From 9903e811c2a0361eaa6f0fa1e823cd626c0f81cf Mon Sep 17 00:00:00 2001 From: Jonathan Kingston Date: Wed, 31 May 2017 15:36:45 +0100 Subject: [PATCH] Fix first focus issue on opening browser action. Fixes #564 --- webextension/js/popup.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/webextension/js/popup.js b/webextension/js/popup.js index 7c43e5d..cac57b6 100644 --- a/webextension/js/popup.js +++ b/webextension/js/popup.js @@ -523,8 +523,14 @@ Logic.registerPanel(P_CONTAINERS_LIST, { /* Not sure why extensions require a focus for the doorhanger, however it allows us to have a tabindex before the first selected item */ - document.addEventListener("focus", () => { + const focusHandler = () => { list.querySelector("tr").focus(); + document.removeEventListener("focus", focusHandler); + }; + document.addEventListener("focus", focusHandler); + /* If the user mousedown's first then remove the focus handler */ + document.addEventListener("mousedown", () => { + document.removeEventListener("focus", focusHandler); }); return Promise.resolve();