Closed Bug 1376088 Opened 7 years ago Closed 4 years ago

tabs.duplicate does not immediately make the duplicated tab active

Categories

(WebExtensions :: General, defect, P5)

defect

Tracking

(firefox79 fixed)

RESOLVED FIXED
mozilla79
Tracking Status
firefox79 --- fixed

People

(Reporter: ke5trel, Assigned: perso)

References

(Blocks 1 open bug)

Details

(Whiteboard: [tabs])

Attachments

(1 file)

STR:

1. Install Duplicate Tab Shortcut:
https://addons.mozilla.org/en-US/firefox/addon/duplicate-tab-shortcut
2. Press Alt+Shift+D to duplicate the current tab.

Expected:

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

Actual:

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 https://bugzilla.mozilla.org/show_bug.cgi?id=1483958
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:
https://searchfox.org/mozilla-central/rev/3262e013550a0db7c1840a78a3878a929801fe40/browser/components/extensions/parent/ext-tabs.js#1104
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
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Pushed by cbrindusan@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/8358b0f93e05
make tab active immediately in tabs.duplicate r=robwu,Gijs
Status: ASSIGNED → RESOLVED
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.

Attachment

General

Creator:
Created:
Updated:
Size: