Bug 1272179 - reset focus whenever the sidebar is hidden. r=bgrins draft
authorYura Zenevich <yzenevich@mozilla.com>
Thu, 12 May 2016 11:24:58 -0400
changeset 366364 c736bf92cc87cf160cdb97f81e46a605bf695ef4
parent 366346 c3f5e6079284a7b7053c41f05d0fe06ff031db03
child 520757 05a6eaa70097c3e7677b2c1b9a7210d9a3f10dc1
push id17963
push useryura.zenevich@gmail.com
push dateThu, 12 May 2016 15:25:34 +0000
reviewersbgrins
bugs1272179
milestone49.0a1
Bug 1272179 - reset focus whenever the sidebar is hidden. r=bgrins MozReview-Commit-ID: FxnbMyEuTzw
devtools/client/framework/sidebar.js
devtools/client/framework/test/browser_toolbox_sidebar.js
--- a/devtools/client/framework/sidebar.js
+++ b/devtools/client/framework/sidebar.js
@@ -491,16 +491,17 @@ ToolSidebar.prototype = {
   },
 
   /**
    * Show the sidebar.
    */
   hide: function() {
     Services.prefs.setIntPref("devtools.toolsidebar-width." + this._uid, this._tabbox.width);
     this._tabbox.setAttribute("hidden", "true");
+    this._panelDoc.activeElement.blur();
 
     this.emit("hide");
   },
 
   /**
    * Return the window containing the tab content.
    */
   getWindowForTab: function(id) {
--- a/devtools/client/framework/test/browser_toolbox_sidebar.js
+++ b/devtools/client/framework/test/browser_toolbox_sidebar.js
@@ -113,17 +113,22 @@ function test() {
     is(label, 4, "Found the right amount of tabs.");
     is(panel.sidebar._tabbox.selectedPanel, panels[0], "First tab is selected");
     is(panel.sidebar.getCurrentTabID(), "tab1", "getCurrentTabID() is correct");
 
     panel.sidebar.once("tab1-unselected", function() {
       ok(true, "received 'unselected' event");
       panel.sidebar.once("tab2-selected", function() {
         ok(true, "received 'selected' event");
+        tabs[1].focus();
+        is(panel.sidebar._panelDoc.activeElement, tabs[1],
+          "Focus is set to second tab");
         panel.sidebar.hide();
+        isnot(panel.sidebar._panelDoc.activeElement, tabs[1],
+          "Focus is reset for sidebar");
         is(panel.sidebar._tabbox.getAttribute("hidden"), "true", "Sidebar hidden");
         is(panel.sidebar.getWindowForTab("tab1").location.href, tab1URL, "Window is accessible");
         testRemoval(panel);
       });
     });
 
     panel.sidebar.select("tab2");
   }