trigger-corp / browser-extensions

Build and run cross-platform browser extensions from one codebase.
Other
312 stars 52 forks source link

Force popup close when new foreground tab is opened (IE) #31

Closed makern closed 10 years ago

makern commented 10 years ago

If a new foreground browser tab is opened from the popup window the expectation is that the popup closes so the user can interact with the opened page.

This sometimes doesn't work properly because window focus is not transferred to the new tab which means the popup doesn't lose focus and closes. I couldn't figure out why this doesn't always work but my guess is that the browser control in the popup somehow takes the focus back or otherwise manages to hold on to it.

This patch forces the popup to close when the forge.tabs.open() api is called with keepFocus == false. It's a bit of a hack but it guarantees the same behaviour as Chrome.

makern commented 10 years ago

Hold off on merging this. I just realised that all browsers have this issue in one way or other. I'll rethink this and probably add a separate API function for the JavaScript in the popup window to close it whenever needed.

window.close() works in chrome but in IE and FF it actually closes the browser instance instead of just hiding the popup which breaks things.

nullrocket commented 10 years ago

I personally rely on the popup staying open when opening/creating a new Tab, interaction within the Popup may not be complete with just the new tab opening. This behavior is desirable for me especially in chrome where the popup DOM has to be recreated each time.

On Wed, May 21, 2014 at 7:50 AM, Markus Kern notifications@github.comwrote:

Hold off on merging this. I just realised that all browsers have this issue in one way or other. I'll rethink this and probably add a separate API function for the JavaScript in the popup window to close it whenever needed.

window.close() works in chrome but in IE and FF it actually closes the browser instance instead of just hiding the popup which breaks things.

— Reply to this email directly or view it on GitHubhttps://github.com/trigger-corp/browser-extensions/pull/31#issuecomment-43756458 .

makern commented 10 years ago

Thanks for the feedback. This patch was definitely a hack and I will abandon it for a better solution which also accommodates your use case.