www

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

commit 3ab335a07815014fab03e4a895436fd124982be2
parent 8c98abe9dc95e94285d18f745f32bfaebf68dc92
Author: Dan Stillman <dstillman@zotero.org>
Date:   Thu,  5 May 2016 02:14:54 -0400

Don't clear search field when updating items list during sync

Fixes #985

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

diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js @@ -796,12 +796,12 @@ Zotero.ItemTreeView.prototype.notify = Zotero.Promise.coroutine(function* (actio // Otherwise re-run the quick search, which refreshes the item list else { - // For item adds, clear the quicksearch, unless all the new items - // are child items + // For item adds, clear the quicksearch, unless all the new items have skipSelect or are + // child items if (activeWindow && type == 'item') { let clear = false; for (let i=0; i<items.length; i++) { - if (items[i].isTopLevelItem()) { + if (!extraData[items[i].id].skipSelect && items[i].isTopLevelItem()) { clear = true; break; } diff --git a/test/tests/itemTreeViewTest.js b/test/tests/itemTreeViewTest.js @@ -9,8 +9,8 @@ describe("Zotero.ItemTreeView", function() { zp = win.ZoteroPane; cv = zp.collectionsView; - var item = new Zotero.Item('book'); - existingItemID = yield item.saveTx(); + var item = yield createDataObject('item', { setTitle: true }); + existingItemID = item.id; }); beforeEach(function* () { yield selectLibrary(win); @@ -137,6 +137,30 @@ describe("Zotero.ItemTreeView", function() { assert.equal(selected[0], existingItemID); }); + it("shouldn't clear quicksearch if skipSelect is passed", function* () { + var searchString = Zotero.Items.get(existingItemID).getField('title'); + + yield createDataObject('item'); + + var quicksearch = win.document.getElementById('zotero-tb-search'); + quicksearch.value = searchString; + quicksearch.doCommand(); + yield itemsView._refreshPromise; + + assert.equal(itemsView.rowCount, 1); + + // Create item with skipSelect flag + var item = new Zotero.Item('book'); + var ran = Zotero.Utilities.randomString(); + item.setField('title', ran); + var id = yield item.saveTx({ + skipSelect: true + }); + + assert.equal(itemsView.rowCount, 1); + assert.equal(quicksearch.value, searchString); + }); + it("shouldn't change selection outside of trash if new trashed item is created with skipSelect", function* () { yield selectLibrary(win); yield waitForItemsLoad(win);