commit 934545260180e5816cbf6e42d7b67e701fd7bdcb
parent 0bab038925c20936cf45b1f96d79ab18c1c7a2cf
Author: Dan Stillman <dstillman@zotero.org>
Date: Mon, 9 May 2016 13:54:19 -0400
Don't restore items tree scroll position if selecting new items
Diffstat:
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js
@@ -487,7 +487,12 @@ Zotero.ItemTreeView.prototype.notify = Zotero.Promise.coroutine(function* (actio
var savedSelection = this.getSelectedItems(true);
var previousFirstSelectedRow = this._rowMap[ids[0]];
- var scrollPosition = this._saveScrollPosition();
+
+ // If there's not at least one new item to be selected, get a scroll position to restore later
+ var scrollPosition = false;
+ if (action != 'add' || ids.every(id => extraData[id] && extraData[id].skipSelect)) {
+ scrollPosition = this._saveScrollPosition();
+ }
// Redraw the tree (for tag color and progress changes)
if (action == 'redraw') {
diff --git a/test/tests/itemTreeViewTest.js b/test/tests/itemTreeViewTest.js
@@ -260,7 +260,7 @@ describe("Zotero.ItemTreeView", function() {
yield Zotero.Items.erase(items.map(item => item.id));
})
- it("should keep first visible item in view when other items are added or removed with skipSelect and nothing in view is selected", function* () {
+ it("should keep first visible item in view when other items are added with skipSelect and nothing in view is selected", function* () {
var collection = yield createDataObject('collection');
yield waitForItemsLoad(win);
itemsView = zp.itemsView;
@@ -311,7 +311,7 @@ describe("Zotero.ItemTreeView", function() {
assert.equal(itemsView.getRow(treebox.getFirstVisibleRow()).ref.id, firstVisibleItemID);
});
- it("should keep first visible selected item in position when other items are added or removed with skipSelect", function* () {
+ it("should keep first visible selected item in position when other items are added with skipSelect", function* () {
var collection = yield createDataObject('collection');
yield waitForItemsLoad(win);
itemsView = zp.itemsView;
@@ -367,7 +367,7 @@ describe("Zotero.ItemTreeView", function() {
assert.equal(newOffset, offset);
});
- it("shouldn't scroll items list if at top when other items are added or removed with skipSelect", function* () {
+ it("shouldn't scroll items list if at top when other items are added with skipSelect", function* () {
var collection = yield createDataObject('collection');
yield waitForItemsLoad(win);
itemsView = zp.itemsView;