tabGroups.onMoved

Fires when a tab group is moved within a window or to another window. tabs.onMoved also fire for the tabs within the group.

The event is passed a tabGroups.TabGroup object. This includes the windowId but not the position of the tab group. To determine the position of the tab group, use tabs.query() with the groupId, and read the index property of the returned tab.

In Chrome, this event doesn't fire when a tab group is moved between windows; instead, the group is removed from one window and created in another (firing tabGroups.onRemoved and tabGroups.onCreated.

Syntax

js
browser.tabGroups.onMoved.addListener(listener)
browser.tabGroups.onMoved.removeListener(listener)
browser.tabGroups.onMoved.hasListener(listener)

Events have three functions:

addListener(listener)

Adds a listener to this event.

removeListener(listener)

Stops listening to this event. The listener argument is the listener to remove.

hasListener(listener)

Checks whether listener is registered for this event. Returns true if it is listening, false otherwise.

addListener syntax

Parameters

listener

The function called when this event occurs. The function is passed this argument:

group

tabGroups.TabGroup. Details of the moved tab group's state.

Examples

Listen for and log tab group movement:

js
function tabGroupMoved(group) {
  console.log(
    `Tab group with ID ${group.id} was moved to window ${group.windowId}.`,
  );
}

browser.tabGroups.onMoved.addListener(tabGroupMoved);

Locate a tab group moved to another window.

js
browser.tabGroups.onMoved.addListener(group => {
  let tabs = await browser.tabs.query({
    groupId: group.id,
  });
  console.log(`Moved tab group to ${tabs[0].index} in window ${group.windowId}`);
});

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Firefox for Android
Safari on iOS
onMoved
Chrome – Full support
Chrome 89 (Release date: 2021-03-02)
footnote
footnote Not fired when tab groups are moved to another window; tabGroups.onRemoved and onCreated are fired instead.
Edge – Full support
Edge 89 (Release date: 2021-03-04)
footnote
footnote Not fired when tab groups are moved to another window; tabGroups.onRemoved and onCreated are fired instead.
Firefox – Full support
Firefox 139 (Release date: 2025-05-27)
footnote Full support
Opera – Full support
Opera 75 (Release date: 2021-03-24)
footnote
footnote Not fired when tab groups are moved to another window; tabGroups.onRemoved and onCreated are fired instead.
Safari – No support
Safari
footnote No support
Firefox for Android – No support
Firefox for Android
footnote No support
Safari on iOS – No support
Safari on iOS
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
See implementation notes.