From a5b3d6440b7407032f1f0290d3da67231bbba062 Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Thu, 31 Mar 2022 17:46:30 -0700 Subject: [PATCH] Fix next duplicates set selection after merge (#2448) --- chrome/content/zotero/itemTree.jsx | 5 ++++- chrome/content/zotero/xpcom/data/items.js | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/itemTree.jsx b/chrome/content/zotero/itemTree.jsx index e09b1cfc0b..690f93af02 100644 --- a/chrome/content/zotero/itemTree.jsx +++ b/chrome/content/zotero/itemTree.jsx @@ -759,7 +759,10 @@ var ItemTree = class ItemTree extends LibraryTree { } // On removal of a selected row, select item at previous position else if (savedSelection.length) { - if ((action == 'remove' || action == 'trash' || action == 'delete') + if ((action == 'remove' + || action == 'trash' + || action == 'delete' + || action == 'removeDuplicatesMaster') && savedSelection.some(id => this.getRowIndexByID(id) === false)) { // In duplicates view, select the next set on delete if (collectionTreeRow.isDuplicates()) { diff --git a/chrome/content/zotero/xpcom/data/items.js b/chrome/content/zotero/xpcom/data/items.js index c2cf421c0d..2af24fff3b 100644 --- a/chrome/content/zotero/xpcom/data/items.js +++ b/chrome/content/zotero/xpcom/data/items.js @@ -1013,13 +1013,14 @@ Zotero.Items = function() { } item.setField('dateAdded', earliestDateAdded); + + // Hack to remove master item from duplicates view without recalculating duplicates + // Pass force = true so observers will be notified before this transaction is committed + yield Zotero.Notifier.trigger('removeDuplicatesMaster', 'item', item.id, null, true); for (let i in toSave) { yield toSave[i].save(); } - - // Hack to remove master item from duplicates view without recalculating duplicates - Zotero.Notifier.trigger('removeDuplicatesMaster', 'item', item.id); }.bind(this)); };