changeset 221:195a5e4f8c9a

a even better way to clear the selection and make sure the new view is visible
author Myk Melez <myk@mozilla.org>
date Wed, 30 Jul 2008 00:25:06 -0700
parents 412c3ccf2e24
children 3e3342270d3d
files extension/content/snowl.js
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/extension/content/snowl.js	Wed Jul 30 00:08:27 2008 -0700
+++ b/extension/content/snowl.js	Wed Jul 30 00:25:06 2008 -0700
@@ -167,7 +167,7 @@
 
     this._collection = new SnowlCollection();
     this._sort();
-    this._rebuildView();
+    this._tree.view = this;
   },
 
   destroy: function() {
@@ -250,11 +250,18 @@
   },
 
   _rebuildView: function() {
+    // Clear the selection before we rebuild the view, since it won't apply
+    // to the new data.
+    this._tree.view.selection.clearSelection();
+
     // Since the number of rows might have changed, we rebuild the view
     // by reinitializing it instead of merely invalidating the box object
     // (which wouldn't accommodate changes to the number of rows).
-    this._tree.view.selection.clearSelection();
+    // XXX Is there a better way to do this?
     this._tree.view = this;
+
+    // Scroll back to the top of the tree.
+    this._tree.boxObject.scrollToRow(this._tree.boxObject.getFirstVisibleRow());
   },
 
   // From toolkit/mozapps/update/content/history.js