Closed Bug 1376088 Opened 7 years ago Closed 4 years ago

tabs.duplicate does not immediately make the duplicated tab active


(WebExtensions :: General, defect, P5)



(firefox79 fixed)

Tracking Status
firefox79 --- fixed


(Reporter: ke5trel, Assigned: aria)


(Blocks 1 open bug)


(Whiteboard: [tabs])


(1 file)


1. Install Duplicate Tab Shortcut:
2. Press Alt+Shift+D to duplicate the current tab.


tabs.duplicate should create a new tab and immediately make it active like Chrome.


New tab is created in background and only after it finishes loading does it become active. This delayed tab switching is not good UX.
Summary: tabs.duplicate makes new tab active only after it finishes loading → tabs.duplicate does not immediately make the duplicated tab active
Whiteboard: [tabs]
If the default behavior will be to activate the tab, then how would it be possible to duplicate without activating?

It seems like `tabs.duplicate(id, {active: false})` should be the way if we need chrome parity, or keep the default as non-active and either add `{active: true}` or keep it as two operations (duplicate and `update(id, {active: true})`).
(In reply to Zibi Braniecki [:gandalf][:zibi] from comment #1)
> or keep it as two operations (duplicate and `update(id, {active: true})`).

The tabs.duplicate() promise is not fulfilled until after the duplicated tab has been fully loaded which is too late for updating the tab's active state. It is possible to add a listener to tabs.onCreated to get the next new tab and immediately update its active state but this is quite hacky. There are currently at least five extensions that do tab duplication (Duplicate Tab Shortcut, Duplicate tab, Undo|Duplicate Tab, Keyboard Shortcut for Tab Duplication and FoxyTab) and none of them do this, suffering from a delay before the duplicated tab is made active.

Chrome is default active and so is Firefox when using middle/ctrl-click on the refresh button (regardless of browser.tabs.loadInBackground) so tabs.duplicate() should also be default active. I can't think of a use case for duplicating tabs in the background myself but it sounds like something that would be nice to have as an option.
Priority: -- → P5
Product: Toolkit → WebExtensions
Bulk move of bugs per
Component: Untriaged → General

Duplicate of bug 1394376

(In reply to ariasuni from comment #4)

Duplicate of bug 1394376

Not a duplicate. In that bug it became possible to prevent a tab from becoming active, which does indeed address the concern from comment 1 here, but it doesn't fix the reported bug.
This bug is about the switching to occur too late.

As you may have noticed, the implementation in ext-tabs.js waits for a content restoration event, supposedly to work around a bug:
This bug could be resolved by activating before that event is fired, either by doing so immediately after tab duplication, or through a new option (aOptions is very useful ;) ).

Do you want to look into this and attach a patch?

Assignee: nobody → perso
Blocks: 1640665
Ever confirmed: true
Pushed by
make tab active immediately in tabs.duplicate r=robwu,Gijs
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla79
You need to log in before you can comment on or make changes to this bug.