diff --git a/chrome/content/zotero/xpcom/recognizePDF.js b/chrome/content/zotero/xpcom/recognizePDF.js index 23f4c96a9..778c8efb9 100644 --- a/chrome/content/zotero/xpcom/recognizePDF.js +++ b/chrome/content/zotero/xpcom/recognizePDF.js @@ -349,6 +349,16 @@ Zotero.RecognizePDF = new function () { throw new Zotero.Exception.Alert('recognizePDF.error'); } + var zp = Zotero.getActiveZoteroPane(); + var selectParent = false; + if (zp) { + let selected = zp.getSelectedItems(); + if (selected.length) { + // If only the PDF was selected, select the parent when we're done + selectParent = selected.length == 1 && selected[0] == attachment; + } + } + let parentItem = await _recognize(attachment); if (!parentItem) { return null; @@ -387,6 +397,18 @@ Zotero.RecognizePDF = new function () { await attachment.saveTx(); } + try { + zp = Zotero.getActiveZoteroPane(); + if (zp) { + if (selectParent) { + await zp.selectItem(parentItem.id); + } + } + } + catch (e) { + Zotero.logError(e); + } + _newItems.set( parentItem, {