diff --git a/chrome/content/zotero/itemTree.jsx b/chrome/content/zotero/itemTree.jsx index c7210d770c..decb66c07c 100644 --- a/chrome/content/zotero/itemTree.jsx +++ b/chrome/content/zotero/itemTree.jsx @@ -3052,13 +3052,23 @@ var ItemTree = class ItemTree extends LibraryTree { var unsuppress = this.selection.selectEventsSuppressed = true; } + let focusedSet = false; + var toggleSelect = (function (itemID) { + if (!focusedSet) { + this.selection.select(this._rowMap[itemID]); + focusedSet = true; + } + else { + this.selection.toggleSelect(this._rowMap[itemID]); + } + }).bind(this); try { for (let i = 0; i < selection.length; i++) { if (this._rowMap[selection[i]] != null) { - this.selection.toggleSelect(this._rowMap[selection[i]]); + toggleSelect(selection[i]); } // Try the parent - else if (expandCollapsedParents) { + else { var item = Zotero.Items.get(selection[i]); if (!item) { continue; @@ -3070,9 +3080,15 @@ var ItemTree = class ItemTree extends LibraryTree { } if (this._rowMap[parent] != null) { - await this._closeContainer(this._rowMap[parent]); - await this.toggleOpenState(this._rowMap[parent]); - this.selection.toggleSelect(this._rowMap[selection[i]]); + if (expandCollapsedParents) { + await this._closeContainer(this._rowMap[parent]); + await this.toggleOpenState(this._rowMap[parent]); + toggleSelect(selection[i]); + } + else { + !this.selection.isSelected(this._rowMap[parent]) && + toggleSelect(parent); + } } } }