From a8dd24ef2d4e17ad05ff86e3b21ee3d1536973ab Mon Sep 17 00:00:00 2001 From: Gijs Kruitbosch Date: Thu, 12 Mar 2015 10:25:20 +0000 Subject: [PATCH] Bug 1128175 - add explicit handler, r=jaws --- .../components/preferences/in-content/subdialogs.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/browser/components/preferences/in-content/subdialogs.js b/browser/components/preferences/in-content/subdialogs.js index 128c12ff60d..406e73844f4 100644 --- a/browser/components/preferences/in-content/subdialogs.js +++ b/browser/components/preferences/in-content/subdialogs.js @@ -222,6 +222,11 @@ let gSubDialog = { }, _onKeyDown: function(aEvent) { + if (aEvent.currentTarget == window && aEvent.keyCode == aEvent.DOM_VK_ESCAPE && + !aEvent.defaultPrevented) { + this.close(aEvent); + return; + } if (aEvent.keyCode != aEvent.DOM_VK_TAB || aEvent.ctrlKey || aEvent.altKey || aEvent.metaKey) { return; @@ -278,6 +283,10 @@ let gSubDialog = { this._frame.addEventListener("load", this); chromeBrowser.addEventListener("unload", this, true); + // Ensure we get keypresses even if nothing in the subdialog is focusable + // (happens on OS X when only text inputs and lists are focusable, and + // the subdialog only has checkboxes/radiobuttons/buttons) + window.addEventListener("keydown", this, true); }, _removeDialogEventListeners: function() { @@ -290,6 +299,7 @@ let gSubDialog = { window.removeEventListener("DOMFrameContentLoaded", this, true); this._frame.removeEventListener("load", this); this._frame.contentWindow.removeEventListener("dialogclosing", this); + window.removeEventListener("keydown", this, true); this._untrapFocus(); },