Bug 1272179 - reset focus whenever the sidebar is hidden. r=bgrins
MozReview-Commit-ID: FxnbMyEuTzw
--- 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");
}