From 359fbbbcd286f16de5b23db5f4bb8dbbb2b5b6ac Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Fri, 9 Jan 2015 09:09:19 +0000 Subject: Modes; fix click handling for all "overlay" modes. From #1413... Go here: http://jsfiddle.net/smblott/9u7geasd/ In the result window: Type /Fish (do not press enter). Click in one of the text areas. Press Esc. Type aaa - you're in insert mode. Type jk - hmm, where did they go? Type o - oops, you're also in normal mode. --- content_scripts/vimium_frontend.coffee | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'content_scripts/vimium_frontend.coffee') diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index d67f57d0..97d4cd73 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -391,18 +391,21 @@ extend window, visibleInputs[selectedInputIndex].element.focus() @suppressEvent else unless event.keyCode == KeyboardUtils.keyCodes.shiftKey - @exit() + @exit event @continueBubbling visibleInputs[selectedInputIndex].element.focus() - return @exit() if visibleInputs.length == 1 - hints[selectedInputIndex].classList.add 'internalVimiumSelectedInputHint' + if visibleInputs.length == 1 + @exit() + else + hints[selectedInputIndex].classList.add 'internalVimiumSelectedInputHint' exit: -> - DomUtils.removeElement hintContainingDiv - visibleInputs[selectedInputIndex].element.focus() - new InsertMode visibleInputs[selectedInputIndex].element super() + DomUtils.removeElement hintContainingDiv + if document.activeElement == visibleInputs[selectedInputIndex].element + # InsertModeBlocker handles the "click" case. + new InsertMode document.activeElement unless event?.type == "click" # Decide whether this keyChar should be passed to the underlying page. # Keystrokes are *never* considered passKeys if the keyQueue is not empty. So, for example, if 't' is a @@ -733,7 +736,7 @@ handleEnterForFindMode = -> document.body.classList.add("vimiumFindMode") settings.set("findModeRawQuery", findModeQuery.rawQuery) -class FindMode extends Mode +class FindMode extends InsertModeBlocker constructor: -> super name: "find" @@ -762,8 +765,9 @@ class FindMode extends Mode exit: (event) -> super() - handleEscapeForFindMode() if event and KeyboardUtils.isEscape event - new PostFindMode findModeAnchorNode + handleEscapeForFindMode() if event?.type == "keydown" and KeyboardUtils.isEscape event + handleEscapeForFindMode() if event?.type == "click" + new PostFindMode findModeAnchorNode unless event?.type == "click" performFindInPlace = -> cachedScrollX = window.scrollX -- cgit v1.2.3