From 9806087e98a9f98b6fbb12d16cc89bf12458b680 Mon Sep 17 00:00:00 2001 From: baku Date: Tue, 28 Feb 2017 18:39:34 +0100 Subject: [PATCH] The context menu must be recreated each time we change tab - issue #289 --- index.js | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 43aeb83..9f01173 100644 --- a/index.js +++ b/index.js @@ -228,15 +228,16 @@ const ContainerService = { tabs.on("activate", tab => { this._hideAllPanels(); this._restyleActiveTab(tab).catch(() => {}); + this._configureActiveWindows(); this._remapTab(tab); }); // Modify CSS and other stuff for each window. - this.configureWindows().catch(() => {}); + this._configureWindows().catch(() => {}); windows.browserWindows.on("open", window => { - this.configureWindow(viewFor(window)).catch(() => {}); + this._configureWindow(viewFor(window)).catch(() => {}); }); windows.browserWindows.on("close", window => { @@ -934,18 +935,30 @@ const ContainerService = { // Styling the window - configureWindows() { + _configureWindows() { const promises = []; for (let window of windows.browserWindows) { // eslint-disable-line prefer-const - promises.push(this.configureWindow(viewFor(window))); + promises.push(this._configureWindow(viewFor(window))); } return Promise.all(promises); }, - configureWindow(window) { + _configureWindow(window) { return this._getOrCreateContainerWindow(window).configure(); }, + _configureActiveWindows() { + const promises = []; + for (let window of windows.browserWindows) { // eslint-disable-line prefer-const + promises.push(this._configureActiveWindow(viewFor(window))); + } + return Promise.all(promises); + }, + + _configureActiveWindow(window) { + return this._getOrCreateContainerWindow(window).configureActive(); + }, + closeWindow(window) { this._windowMap.delete(window); }, @@ -1136,11 +1149,15 @@ ContainerWindow.prototype = { this._configureActiveTab(), this._configureFileMenu(), this._configureAllTabsMenu(), - this._configureContextMenu(), this._configureTabStyle(), + this.configureActive(), ]); }, + configureActive() { + return this._configureContextMenu(); + }, + handleEvent(e) { let el = e.target; switch (e.type) {