www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 0d1d4ee5cbb27c733bec252fb12623c5ced1ab52
parent 27f6f018d379941b3294a45f3dd7ff15fc83f593
Author: Dan Stillman <dstillman@zotero.org>
Date:   Tue, 23 Jun 2015 16:56:10 -0400

Don't change selection unnecessarily when creating trashed item

Diffstat:
Mchrome/content/zotero/xpcom/itemTreeView.js | 35+++++++++++------------------------
Mtest/tests/itemTreeViewTest.js | 17+++++++++++++++++
2 files changed, 28 insertions(+), 24 deletions(-)

diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js @@ -823,14 +823,14 @@ Zotero.ItemTreeView.prototype.notify = Zotero.Promise.coroutine(function* (actio } } + if (sort) { + yield this.sort(typeof sort == 'number' ? sort : false); + } + else { + this._refreshItemRowMap(); + } + if (singleSelect) { - if (sort) { - yield this.sort(typeof sort == 'number' ? sort : false); - } - else { - this._refreshItemRowMap(); - } - if (!extraData[singleSelect] || !extraData[singleSelect].skipSelect) { // Reset to Info tab this._ownerDocument.getElementById('zotero-view-tabbox').selectedIndex = 0; @@ -841,19 +841,14 @@ Zotero.ItemTreeView.prototype.notify = Zotero.Promise.coroutine(function* (actio else if (action == 'modify' && ids.length == 1 && savedSelection.length == 1 && savedSelection[0] == ids[0]) { // If the item no longer matches the search term, clear the search + // DEBUG: Still needed/wanted? (and search is async, so doesn't work anyway, + // here or above) if (quicksearch && this._rowMap[ids[0]] == undefined) { Zotero.debug('Selected item no longer matches quicksearch -- clearing'); quicksearch.value = ''; quicksearch.doCommand(); } - if (sort) { - yield this.sort(typeof sort == 'number' ? sort : false); - } - else { - this._refreshItemRowMap(); - } - if (activeWindow) { yield this.selectItem(ids[0]); } @@ -861,16 +856,8 @@ Zotero.ItemTreeView.prototype.notify = Zotero.Promise.coroutine(function* (actio yield this.rememberSelection(savedSelection); } } - else - { - if (sort) { - yield this.sort(typeof sort == 'number' ? sort : false); - } - else { - this._refreshItemRowMap(); - } - - // On removal of a row, select item at previous position + // On removal of a row, select item at previous position + else if (savedSelection.length) { if (action == 'remove' || action == 'trash' || action == 'delete') { // In duplicates view, select the next set on delete if (collectionTreeRow.isDuplicates()) { diff --git a/test/tests/itemTreeViewTest.js b/test/tests/itemTreeViewTest.js @@ -116,6 +116,23 @@ describe("Zotero.ItemTreeView", function() { assert.equal(selected[0], existingItemID); }); + it("shouldn't change selection outside of trash if new trashed item is created with skipSelect", function* () { + yield selectLibrary(win); + yield waitForItemsLoad(win); + + itemsView.selection.clearSelection(); + + var item = createUnsavedDataObject('item'); + item.deleted = true; + var id = yield item.saveTx({ + skipSelect: true + }); + + // Nothing should be selected + selected = itemsView.getSelectedItems(true); + assert.lengthOf(selected, 0); + }) + it("shouldn't select a modified item", function* () { // Create item var item = new Zotero.Item('book');