From 5b6014c2f6d3fa24c04fbb5435fe79896f400001 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Mon, 16 Feb 2015 11:02:53 +0000 Subject: 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. --- pages/vomnibar.coffee | 18 +++++++++++------- 1 file 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() # 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() -- cgit v1.2.3