From ebd3d7a9889b0e6503e893c7825b7b84af1ef628 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 1 Feb 2024 00:51:31 -0500 Subject: [PATCH] Fix wrong tab being selected after Reopen Closed Tab Fixes #3651 --- chrome/content/zotero/tabs.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/chrome/content/zotero/tabs.js b/chrome/content/zotero/tabs.js index 6e81c0fdca..f5db264c09 100644 --- a/chrome/content/zotero/tabs.js +++ b/chrome/content/zotero/tabs.js @@ -347,24 +347,26 @@ var Zotero_Tabs = new function () { /** * Undo tabs closing */ - this.undoClose = function () { + this.undoClose = async function () { var historyEntry = this._history.pop(); if (historyEntry) { let maxIndex = -1; + let openPromises = []; for (let tab of historyEntry) { if (Zotero.Items.exists(tab.data.itemID)) { - Zotero.Reader.open(tab.data.itemID, + openPromises.push(Zotero.Reader.open(tab.data.itemID, null, { tabIndex: tab.index, openInBackground: true } - ); + )); if (tab.index > maxIndex) { maxIndex = tab.index; } } } + await Promise.all(openPromises); // Select last reopened tab if (maxIndex > -1) { this.jump(maxIndex);