From 9c96f750f7c2d22eb0098dcb05b34c51c802e8ac Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sun, 27 Mar 2016 12:20:39 +0100 Subject: Handle focus events for UI components. The help-dialog UI component was ignoring requests to "hide" when other frames are focused (because previously it covered the whole screen, and no other frame could get the focus). With f0911e52f0e71c6d2539bdc74a09ff2dbd5ab125, the help dialog no longer covers the whole screen, so it must listen for and react to "frameFocused" events. However, the help dialog should not "hide" when the frame that is focused is itself! This required a little extra plumbing. That plumbing is helpful, though, because it allows individual UI components to decide what to do when another frame receives the focus (as opposed to the previious version, which simply unilaterally sent a "hide" message). --- content_scripts/ui_component.coffee | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'content_scripts') diff --git a/content_scripts/ui_component.coffee b/content_scripts/ui_component.coffee index d381cb0f..ac0bea71 100644 --- a/content_scripts/ui_component.coffee +++ b/content_scripts/ui_component.coffee @@ -48,11 +48,9 @@ class UIComponent @iframeElement.contentWindow.postMessage vimiumSecret, chrome.runtime.getURL(""), [ port2 ] setIframePort port1 - # If any other frame in the current tab receives the focus, then we hide the UI component. - # NOTE(smblott) This is correct for the vomnibar, but might be incorrect (and need to be revisited) for - # other UI components. chrome.runtime.onMessage.addListener (request) => - @postMessage "hide" if @showing and request.name == "frameFocused" and request.focusFrameId != frameId + if @showing and request.name == "frameFocused" and request.focusFrameId != frameId + @postMessage name: "frameFocused", focusFrameId: request.focusFrameId false # Free up the sendResponse handler. # Posts a message (if one is provided), then calls continuation (if provided). The continuation is only -- cgit v1.2.3