# HG changeset patch # User Guido Berhoerster # Date 1487610420 -3600 # Node ID e32b90567f39499725730cf42a10ffe57aca9a9e # Parent 5d79143077821003ab24431957f1e0b547d32192 Update menu when reopening a tab Creating a tab changes the focused tab in the destination window, thus the menu item representing the destination window needs to be updated. diff -r 5d7914307782 -r e32b90567f39 background.js --- a/background.js Mon Feb 20 17:40:31 2017 +0100 +++ b/background.js Mon Feb 20 18:07:00 2017 +0100 @@ -366,23 +366,33 @@ } onMenuItemClicked(info, tab) { + var windowId = parseInt(info.menuItemId); + if (info.parentMenuItemId === 'move-menu') { // move tab from the current window to the selected window browser.tabs.move(tab.id, { - windowId: parseInt(info.menuItemId), + windowId, index: -1 }).catch(error => { console.log('Error:', error); }); } else { - // open the URL of the current tab in the selected window and close - // the current tab + // open the URL of the current tab in the destination window browser.tabs.create({ url: tab.url, - windowId: parseInt(info.menuItemId), + windowId, index: -1 }).then(newTab => { + // close the current tab return browser.tabs.remove(tab.id); + }).then(() => { + // get the new title of the destination window + return browser.tabs.query({ + active: true, + windowId + }); + }).then(tabs => { + this.model.updateWindowTitle(windowId, tabs[0].title) }).catch(error => { console.log('Error:', error); });