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/mode_insert.coffee | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'content_scripts/mode_insert.coffee') diff --git a/content_scripts/mode_insert.coffee b/content_scripts/mode_insert.coffee index 7f1d5ddc..bfc79aa9 100644 --- a/content_scripts/mode_insert.coffee +++ b/content_scripts/mode_insert.coffee @@ -64,6 +64,19 @@ class InsertModeBlocker extends Mode super options @onExit -> triggerSuppressor.unsuppress() + @push + "click": (event) => + @alwaysContinueBubbling => + # The user knows best; so, if the user clicks on something, we get out of the way. + @exit event + # However, there's a corner case. If the active element is focusable, then we would have been in + # insert mode had we not been blocking the trigger. Now, clicking on the element will not generate + # a new focus event, so the insert-mode trigger will not fire. We have to handle this case + # specially. + if document.activeElement and + event.target == document.activeElement and DomUtils.isEditable document.activeElement + new InsertMode document.activeElement + root = exports ? window root.InsertMode = InsertMode root.InsertModeTrigger = InsertModeTrigger -- cgit v1.2.3