Fix intermittent item selection failure

This commit is contained in:
Dan Stillman 2017-09-10 03:18:25 -04:00
parent d271683968
commit 2901174ba3
4 changed files with 14 additions and 9 deletions

View file

@ -38,6 +38,7 @@ Zotero.CollectionTreeView = function()
{
Zotero.LibraryTreeView.apply(this);
this.itemTreeView = null;
this.itemToSelect = null;
this.hideSources = [];
@ -1179,11 +1180,9 @@ Zotero.CollectionTreeView.prototype.selectItem = Zotero.Promise.coroutine(functi
yield this.selectLibrary(item.libraryID);
}
var itemsView = this.selectedTreeRow.itemTreeView;
yield this.itemTreeView.waitForLoad();
yield itemsView.waitForLoad();
var selected = yield itemsView.selectItem(itemID, expand);
var selected = yield this.itemTreeView.selectItem(itemID, expand);
if (selected) {
return true;
}
@ -1197,10 +1196,9 @@ Zotero.CollectionTreeView.prototype.selectItem = Zotero.Promise.coroutine(functi
yield this.selectLibrary(item.libraryID);
}
itemsView = this.selectedTreeRow.itemTreeView;
yield itemsView.waitForLoad();
yield this.itemTreeView.waitForLoad();
return itemsView.selectItem(itemID, expand);
return this.itemTreeView.selectItem(itemID, expand);
});

View file

@ -40,7 +40,6 @@ Zotero.ItemTreeView = function (collectionTreeRow) {
this.wrappedJSObject = this;
this.rowCount = 0;
this.collectionTreeRow = collectionTreeRow;
collectionTreeRow.itemTreeView = this;
this._skipKeypress = false;

View file

@ -1225,7 +1225,7 @@ var ZoteroPane = new function()
this._updateToolbarIconsForRow(collectionTreeRow);
this.itemsView = new Zotero.ItemTreeView(collectionTreeRow);
this.itemsView = this.collectionsView.itemTreeView = new Zotero.ItemTreeView(collectionTreeRow);
if (collectionTreeRow.isPublications()) {
this.itemsView.collapseAll = true;
}

View file

@ -62,6 +62,14 @@ describe("Zotero.CollectionTreeView", function() {
assert.isTrue(cv.isContainerOpen(group1Row));
assert.isFalse(cv.isContainerOpen(group2Row));
});
it("should update associated item tree view", function* () {
var collection = yield createDataObject('collection');
var item = yield createDataObject('item', { collections: [collection.id] });
yield cv.reload();
yield cv.selectCollection(collection.id);
yield cv.selectItem(item.id);
});
});
describe("collapse/expand", function () {