aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts/mode_insert.coffee
diff options
context:
space:
mode:
authorStephen Blott2015-01-09 09:09:19 +0000
committerStephen Blott2015-01-09 09:09:19 +0000
commit359fbbbcd286f16de5b23db5f4bb8dbbb2b5b6ac (patch)
tree19deb06a3c9a2523cf1ae81c227efaa9ff29f786 /content_scripts/mode_insert.coffee
parentb20413692cc6fa1cd9ace5cbb04730b6fd139928 (diff)
downloadvimium-359fbbbcd286f16de5b23db5f4bb8dbbb2b5b6ac.tar.bz2
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.
Diffstat (limited to 'content_scripts/mode_insert.coffee')
-rw-r--r--content_scripts/mode_insert.coffee13
1 files changed, 13 insertions, 0 deletions
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