Back to Content

sidebarAction.close()

files/en-us/mozilla/add-ons/webextensions/api/sidebaraction/close/index.md

latest870 B
Original Source

Closes the sidebar in the active window, if it is the extension's own sidebar.

You can only call this function from inside the handler for a user action.

This is an asynchronous function that returns a Promise.

Syntax

js-nolint
browser.sidebarAction.close()

Parameters

None.

Return value

A Promise that is resolved with no arguments.

Examples

Close the sidebar when the user selects a context menu item:

js
browser.menus.create({
  id: "close-sidebar",
  title: "close sidebar",
  contexts: ["all"],
});

browser.menus.onClicked.addListener(() => {
  browser.sidebarAction.close();
});

{{WebExtExamples}}

Browser compatibility

{{Compat}}