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

Fixes #985
This commit is contained in:
Dan Stillman 2016-05-05 02:14:54 -04:00
parent 8c98abe9dc
commit 3ab335a078
2 changed files with 29 additions and 5 deletions

View file

@ -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;
}

View file

@ -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);