From 6bcf92db4668c95ff2a2f5723eaab96263291c10 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 12 Aug 2017 02:50:27 +0200 Subject: [PATCH] Fix "Open in Library" from Quick Format popup if main window is closed Possible now on macOS --- .../content/zotero/integration/quickFormat.js | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/chrome/content/zotero/integration/quickFormat.js b/chrome/content/zotero/integration/quickFormat.js index e1d8af526a..5aa1d4c5fe 100644 --- a/chrome/content/zotero/integration/quickFormat.js +++ b/chrome/content/zotero/integration/quickFormat.js @@ -1301,15 +1301,23 @@ var Zotero_QuickFormat = new function () { /** * Show an item in the library it came from */ - this.showInLibrary = function() { + this.showInLibrary = async function() { var id = panelRefersToBubble.citationItem.id; var pane = Zotero.getActiveZoteroPane(); - if(pane) { - pane.show(); - pane.selectItem(id); - } else { - var win = window.open('zotero://select/item/'+id); + // Open main window if it's not open (Mac) + if (!pane) { + let win = Zotero.openMainWindow(); + await new Zotero.Promise((resolve) => { + let onOpen = function () { + win.removeEventListener('load', onOpen); + resolve(); + }; + win.addEventListener('load', onOpen); + }); + pane = win.ZoteroPane; } + pane.show(); + pane.selectItem(id); // Pull window to foreground Zotero.Integration.activate(pane.document.defaultView);