Fix the opening of a link from a context menu - issue #327

This commit is contained in:
baku 2017-03-20 14:39:07 +01:00
parent 52ceef8586
commit 82cad13630

View file

@ -1370,7 +1370,8 @@ ContainerWindow.prototype = {
}, },
_configureContextMenu() { _configureContextMenu() {
return this._configureMenu("context-openlinkinusercontext-menu", return Promise.all([
this._configureMenu("context-openlinkinusercontext-menu",
() => { () => {
// This userContextId is what we want to exclude. // This userContextId is what we want to exclude.
const tab = modelFor(this._window).tabs.activeTab; const tab = modelFor(this._window).tabs.activeTab;
@ -1388,7 +1389,29 @@ ContainerWindow.prototype = {
window: this._window, window: this._window,
}); });
} }
); ),
this._configureContextMenuOpenLink(),
]);
},
_configureContextMenuOpenLink() {
return new Promise(resolve => {
const self = this;
this._window.gSetUserContextIdAndClick = function(event) {
const tab = modelFor(self._window).tabs.activeTab;
const userContextId = ContainerService._getUserContextIdFromTab(tab);
event.target.setAttribute("data-usercontextid", userContextId);
self._window.gContextMenu.openLinkInTab(event);
};
let item = this._window.document.getElementById("context-openlinkincontainertab");
item.setAttribute("oncommand", "gSetUserContextIdAndClick(event)");
item = this._window.document.getElementById("context-openlinkintab");
item.setAttribute("oncommand", "gSetUserContextIdAndClick(event)");
resolve();
});
}, },
// Generic menu configuration. // Generic menu configuration.