Scroll to new collections, and stay on same row when deleting collections

This commit is contained in:
Dan Stillman 2014-08-12 22:19:19 -04:00
parent 6dbcdb95f4
commit 9db4927f78
2 changed files with 12 additions and 6 deletions

View file

@ -245,7 +245,7 @@ Zotero.CollectionTreeView.prototype.notify = Zotero.Promise.coroutine(function*
var savedSelection = this.saveSelection();
if (action == 'delete') {
var selectedIndex = this.selection.count ? this.selection.selectedIndex : 0;
var selectedIndex = this.selection.count ? this.selection.currentIndex : 0;
//Since a delete involves shifting of rows, we have to do it in order
@ -287,14 +287,18 @@ Zotero.CollectionTreeView.prototype.notify = Zotero.Promise.coroutine(function*
for(var i=0, len=rows.length; i<len; i++)
{
var row = rows[i];
this._removeRow(row-i);
this._treebox.rowCountChanged(row-i,-1);
this._removeRow(row);
this._treebox.rowCountChanged(row, -1);
}
this._refreshCollectionRowMap();
}
if (!this.selection.count) {
// If last row was selected, stay on the last row
if (selectedIndex >= this.rowCount) {
selectedIndex = this.rowCount - 1;
};
this.selection.select(selectedIndex)
}
}
@ -343,7 +347,9 @@ Zotero.CollectionTreeView.prototype.notify = Zotero.Promise.coroutine(function*
this.rememberSelection(savedSelection);
break;
}
this.selection.select(this._collectionRowMap[collection.id]);
let row = this._collectionRowMap[collection.id];
this._treebox.ensureRowIsVisible(row);
this.selection.select(row);
break;
case 'search':

View file

@ -646,12 +646,12 @@ Zotero.ItemTreeView.prototype.notify = Zotero.Promise.coroutine(function* (actio
// The container refresh above takes care of adding the new row.
else if (!this.isContainer(row) && parentIndex == -1 && parentItemID) {
this._removeRow(row);
this._treebox.rowCountChanged(row + 1, -1)
this._treebox.rowCountChanged(row, -1)
}
// If moved from under another item to top level, remove old row and add new one
else if (!this.isContainer(row) && parentIndex != -1 && !parentItemID) {
this._removeRow(row);
this._treebox.rowCountChanged(row + 1, -1)
this._treebox.rowCountChanged(row, -1)
this._addRow(
this._rows,