diff options
| author | Stephen Blott | 2015-02-16 11:02:53 +0000 | 
|---|---|---|
| committer | Stephen Blott | 2015-03-06 13:05:32 +0000 | 
| commit | 5b6014c2f6d3fa24c04fbb5435fe79896f400001 (patch) | |
| tree | 5f95b7171cbf08630e46446a9ac8cd9602d675ef | |
| parent | 52c06b16325968289890dab2133f2ec33540fcb4 (diff) | |
| download | vimium-5b6014c2f6d3fa24c04fbb5435fe79896f400001.tar.bz2 | |
Add short delay before launching from vomnibar.
This is not entirely satisfactory.  It would be great if a delay of 0
worked (a la `nextTick`).  But it seems we need a little longer because
we need to allow the UI component messaging to complete.
An alternative would be to thread the action required through the UI
component logic.  But that's pretty ugly too.
Yet another alternative would be to have the UI Component post an "ok,
we're done, do it" message once the UI component has been removed.
Fixes #1485.
| -rw-r--r-- | pages/vomnibar.coffee | 18 | 
1 files changed, 11 insertions, 7 deletions
| diff --git a/pages/vomnibar.coffee b/pages/vomnibar.coffee index d0b7a7dd..8243b696 100644 --- a/pages/vomnibar.coffee +++ b/pages/vomnibar.coffee @@ -59,9 +59,13 @@ class VomnibarUI    setForceNewTab: (forceNewTab) -> @forceNewTab = forceNewTab -  hide: -> +  # Hide the vomnibar, then call callback.  We add a short delay to allow the vomnibar to close before the +  # action is performed.  This ensures (hopefully) that the vomnibar isn't visible when the tab is +  # subsequently refocused (see #1485). +  hide: (callback = ->) ->      UIComponentServer.postMessage "hide"      @reset() +    setTimeout callback, 20    reset: ->      @completionList.style.display = "" @@ -123,15 +127,15 @@ class VomnibarUI          query = @input.value.trim()          # <Enter> on an empty vomnibar is a no-op.          return unless 0 < query.length -        @hide() -        chrome.runtime.sendMessage({ -          handler: if openInNewTab then "openUrlInNewTab" else "openUrlInCurrentTab" -          url: query }) +        @hide -> +          chrome.runtime.sendMessage +            handler: if openInNewTab then "openUrlInNewTab" else "openUrlInCurrentTab" +            url: query        else          @update true, =>            # Shift+Enter will open the result in a new tab instead of the current tab. -          @completions[@selection].performAction(openInNewTab) -          @hide() +          completion = @completions[@selection] +          @hide -> completion.performAction openInNewTab      # It seems like we have to manually suppress the event here and still return true.      event.stopImmediatePropagation() | 
