Bug 1272179 - reset focus whenever the sidebar is hidden. r=bgrins
authorYura Zenevich <yzenevich@mozilla.com>
Thu, 12 May 2016 11:24:58 -0400
changeset 297190 2e992920def87996ab9a9cd90ac16864248e9044
parent 297189 ffb2b701ce2fc04bb5f93b81c9845d24d1055746
child 297191 8b2fb1aabf141e0c9f9d1f75af9b130c56733217
push id76643
push useryura.zenevich@gmail.com
push dateThu, 12 May 2016 17:41:48 +0000
treeherdermozilla-inbound@2e992920def8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgrins
bugs1272179
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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");
   }