Show tabs before opening a link from the context menu - #288
This commit is contained in:
parent
dba0b97072
commit
29dc974fd6
1 changed files with 25 additions and 7 deletions
26
index.js
26
index.js
|
@ -584,8 +584,15 @@ const ContainerService = {
|
|||
|
||||
const promises = [];
|
||||
|
||||
for (let object of this._identitiesState[args.userContextId].hiddenTabs) { // eslint-disable-line prefer-const
|
||||
promises.push(this.openTab({ userContextId: args.userContextId, url: object.url }));
|
||||
const hiddenTabs = this._identitiesState[args.userContextId].hiddenTabs;
|
||||
this._identitiesState[args.userContextId].hiddenTabs = [];
|
||||
|
||||
for (let object of hiddenTabs) { // eslint-disable-line prefer-const
|
||||
promises.push(this.openTab({
|
||||
userContextId: args.userContextId,
|
||||
url: object.url,
|
||||
nofocus: args.nofocus || false,
|
||||
}));
|
||||
}
|
||||
|
||||
this._identitiesState[args.userContextId].hiddenTabs = [];
|
||||
|
@ -773,6 +780,7 @@ const ContainerService = {
|
|||
return this._recentBrowserWindow().then(browserWin => {
|
||||
const userContextId = ("userContextId" in args) ? args.userContextId : 0;
|
||||
const source = ("source" in args) ? args.source : null;
|
||||
const nofocus = ("nofocus" in args) ? args.nofocus : false;
|
||||
|
||||
// Only send telemetry for tabs opened by UI - i.e., not via showTabs
|
||||
if (source && userContextId) {
|
||||
|
@ -793,8 +801,10 @@ const ContainerService = {
|
|||
|
||||
return promise.then(() => {
|
||||
const tab = browserWin.gBrowser.addTab(args.url || DEFAULT_TAB, { userContextId });
|
||||
if (!nofocus) {
|
||||
browserWin.gBrowser.selectedTab = tab;
|
||||
browserWin.focusAndSelectUrlBar();
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}).catch(() => false);
|
||||
|
@ -1253,11 +1263,16 @@ ContainerWindow.prototype = {
|
|||
_configureAllTabsMenu() {
|
||||
return this._configureMenu("alltabs_containersTab", null, e => {
|
||||
const userContextId = parseInt(e.target.getAttribute("data-usercontextid"), 10);
|
||||
ContainerService.openTab({
|
||||
userContextId: userContextId,
|
||||
ContainerService.showTabs({
|
||||
userContextId,
|
||||
nofocus: true
|
||||
}).then(() => {
|
||||
return ContainerService.openTab({
|
||||
userContextId,
|
||||
source: "alltabs-menu"
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
_configureContextMenu() {
|
||||
|
@ -1271,6 +1286,9 @@ ContainerWindow.prototype = {
|
|||
// This is a super internal method. Hopefully it will be stable in the
|
||||
// next FF releases.
|
||||
this._window.gContextMenu.openLinkInTab(e);
|
||||
|
||||
let userContextId = parseInt(e.target.getAttribute('data-usercontextid'), 10);
|
||||
ContainerService.showTabs({ userContextId, nofocus: true });
|
||||
}
|
||||
);
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue