diff options
Diffstat (limited to 'content_scripts')
| -rw-r--r-- | content_scripts/mode.coffee | 7 | ||||
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 4 |
2 files changed, 10 insertions, 1 deletions
diff --git a/content_scripts/mode.coffee b/content_scripts/mode.coffee index 7877d97c..fa583a1c 100644 --- a/content_scripts/mode.coffee +++ b/content_scripts/mode.coffee @@ -86,6 +86,13 @@ class Mode _name: "mode-#{@id}/exitOnClick" "click": (event) => @alwaysContinueBubbling => @exit event + #If @options.exitOnFocus is truthy, then the mode will exit whenever a focusable element is activated. + if @options.exitOnFocus + @push + _name: "mode-#{@id}/exitOnFocus" + "focus": (event) => @alwaysContinueBubbling => + @exit event if DomUtils.isFocusable event.target + # Some modes are singletons: there may be at most one instance active at any time. A mode is a singleton # if @options.singleton is truthy. The value of @options.singleton should be the key which is intended to # be unique. New instances deactivate existing instances with the same key. diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 5bad1148..609b6b40 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -338,7 +338,9 @@ extend window, HUD.showForDuration("Yanked #{url}", 2000) enterInsertMode: -> - new InsertMode global: true + # If a focusable element receives the focus, then we exit and leave the permanently-installed insert-mode + # instance to take over. + new InsertMode global: true, exitOnFocus: true enterVisualMode: -> new VisualMode() |
