diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js index 76f52b2fa..6b5b173b8 100644 --- a/chrome/content/zotero/xpcom/itemTreeView.js +++ b/chrome/content/zotero/xpcom/itemTreeView.js @@ -622,7 +622,8 @@ Zotero.ItemTreeView.prototype.notify = Zotero.Promise.coroutine(function* (actio var zp = Zotero.getActiveZoteroPane(); var activeWindow = zp && zp.itemsView == this; - var quicksearch = this._ownerDocument.getElementById('zotero-tb-search'); + var quickSearch = this._ownerDocument.getElementById('zotero-tb-search'); + var hasQuickSearch = quickSearch && quickSearch.value != ''; // 'collection-item' ids are in the form collectionID-itemID if (type == 'collection-item') { @@ -699,7 +700,8 @@ Zotero.ItemTreeView.prototype.notify = Zotero.Promise.coroutine(function* (actio // If saved search, publications, or trash, just re-run search if (collectionTreeRow.isSearch() || collectionTreeRow.isPublications() - || collectionTreeRow.isTrash()) { + || collectionTreeRow.isTrash() + || hasQuickSearch) { let skipExpandMatchParents = collectionTreeRow.isPublications(); yield this.refresh(skipExpandMatchParents); refreshed = true; @@ -710,14 +712,11 @@ Zotero.ItemTreeView.prototype.notify = Zotero.Promise.coroutine(function* (actio sort = true; } } - else if (collectionTreeRow.isFeed()) { this._ownerDocument.defaultView.ZoteroPane.updateReadLabel(); } - - // If no quicksearch, process modifications manually - else if (!quicksearch || quicksearch.value == '') - { + // If not a search, process modifications manually + else { var items = Zotero.Items.get(ids); for (let i = 0; i < items.length; i++) { @@ -797,33 +796,6 @@ Zotero.ItemTreeView.prototype.notify = Zotero.Promise.coroutine(function* (actio sort = true; } } - - // If quicksearch, re-run it, since the results may have changed - else - { - var allDeleted = true; - var isTrash = collectionTreeRow.isTrash(); - var items = Zotero.Items.get(ids); - for (let item of items) { - // If not viewing trash and all items were deleted, ignore modify - if (allDeleted && !isTrash && !item.deleted) { - allDeleted = false; - } - } - - if (!allDeleted) { - quicksearch.doCommand(); - // See _refreshPromise note below - if (this._refreshPromise) { - try { - yield this._refreshPromise; - } - catch (e) {} - } - madeChanges = true; - sort = true; - } - } } else if(type == 'item' && action == 'add') { @@ -833,16 +805,32 @@ Zotero.ItemTreeView.prototype.notify = Zotero.Promise.coroutine(function* (actio if (collectionTreeRow.isSearch() || collectionTreeRow.isPublications() || collectionTreeRow.isTrash() - || collectionTreeRow.isUnfiled()) { + || collectionTreeRow.isUnfiled() + || hasQuickSearch) { + if (hasQuickSearch) { + // For item adds, clear the quick search, unless all the new items have + // skipSelect or are child items + if (activeWindow && type == 'item') { + let clear = false; + for (let i=0; i