Don't restore items tree scroll position if selecting new items

This commit is contained in:
Dan Stillman 2016-05-09 13:54:19 -04:00
parent 0bab038925
commit 9345452601
2 changed files with 9 additions and 4 deletions

View file

@ -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') {

View file

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