From 9db4927f78e7aed501dc92876500e26e59b79b6e Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 12 Aug 2014 22:19:19 -0400 Subject: [PATCH] Scroll to new collections, and stay on same row when deleting collections --- chrome/content/zotero/xpcom/collectionTreeView.js | 14 ++++++++++---- chrome/content/zotero/xpcom/itemTreeView.js | 4 ++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/chrome/content/zotero/xpcom/collectionTreeView.js b/chrome/content/zotero/xpcom/collectionTreeView.js index 006b95a697..dd549a6cd4 100644 --- a/chrome/content/zotero/xpcom/collectionTreeView.js +++ b/chrome/content/zotero/xpcom/collectionTreeView.js @@ -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= 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': diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js index 6c56913079..01a162d14c 100644 --- a/chrome/content/zotero/xpcom/itemTreeView.js +++ b/chrome/content/zotero/xpcom/itemTreeView.js @@ -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,