From 11ade4ed2dae1b6f873d5c33e533f39a03838adf Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sun, 27 Mar 2016 06:50:18 +0100 Subject: Escape closes help dialog. With the help dialog in an iframe, Escape no longer closes it if that iframe loses the focus. This fixes that. See point 2 of #2045. This is not a perfect solution: it only works if the focus ends up in the frame from which the help dialog was launched. However, that is the the common case and, in particular, it is the case which arises on the options page -- which is a particularly important use case. --- content_scripts/mode_key_handler.coffee | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'content_scripts') diff --git a/content_scripts/mode_key_handler.coffee b/content_scripts/mode_key_handler.coffee index bafdfd56..cc9ef10f 100644 --- a/content_scripts/mode_key_handler.coffee +++ b/content_scripts/mode_key_handler.coffee @@ -37,12 +37,17 @@ class KeyHandlerMode extends Mode onKeydown: (event) -> keyChar = KeyboardUtils.getKeyCharString event isEscape = KeyboardUtils.isEscape event - if isEscape and @countPrefix == 0 and @keyState.length == 1 - @continueBubbling - else if isEscape + if isEscape and (@countPrefix != 0 or @keyState.length != 1) @keydownEvents[event.keyCode] = true @reset() false # Suppress event. + # If the help dialog loses the focus, then Escape should hide it; see point 2 in #2045. + else if isEscape and HelpDialog?.showing + @keydownEvents[event.keyCode] = true + HelpDialog.hide() + @stopBubblingAndTrue + else if isEscape + @continueBubbling else if @isMappedKey keyChar @keydownEvents[event.keyCode] = true @handleKeyChar keyChar -- cgit v1.2.3