[WebExtension] Prevent a popup panel to hide itself

Hello *,

By default, a panel opened with a BrowserAction autohide itself as soon as it loses the focus.

How to prevent this behavior ?
I’d like it closes only when clicking on a close button.

Thanks.

I’m pretty sure that is not possible.

If you need this for debugging, there is a symbol at the top-right of the extension debugger.

If you want to deploy it, you have to use popup windows instead of the panel. You can open one at the position of the panel in an browserAction.onClicked handler. I do something similar for a different reason. This is my code to position the popup approximately where the panel would be:

const getActive = browser.tabs.query({ currentWindow: true, active: true, });
const parent = (await browser.windows.getLastFocused());
 // the pop-up will not resize itself as the panel would, so the dimensions can be passed as query params 'w' and 'h'
const width = (options.width <<0 || 700) + 14, height = (options.height <<0 || 600) + 42; // the maximum size for panels is somewhere around 700x800. Firefox needs some additional pixels: 14x42 for FF54 on Win 10 with dpi 1.25
const left = Math.round(parent.left + parent.width - width - 25);
const top = Math.round(parent.top + 74); // the actual frame height of the main window varies, but 74px should place the pop-up at the bottom if the button

(await browser.windows.create({
	type: 'popup', url, top, left, width, height,
}));
(await browser.windows.update(windowId, { top, left, })); // firefox currently ignores top and left in .create(), so move it here

function getUrl(query = options) { return location.href.replace(/(?:\?.*?)?(?=#.*|$)/, query ? '?'+ query : ''); } // update query

Thanks for the answer.

Actually, I already tried to use the “popup” window. And it doesn’t look like a popup panel. AFAIK, “popup” window looks like “panel” window and “detached_panel” window. I see no difference at all between them. That’s weird.

I don’t know what you mean by “detached_panel”.

Anyway, the WindowTypw panel is not the same as the browserAction panel. It was a type of window that could be snapped at the bottom of the screen. Chrome supported it for a while. Now Firefox and Chrome treat it the same as popup.

In:


the type attribute can be of value defined there:

That’s where I saw the “detached_panel” window. No idea what that should be. When I tried it, it did the same thing than “popup” and “panel”.