Bug 479384 - Reset button in Library search box is broken, r=dietrich, a=blocking191
authorDrew Willcoxon <adw@mozilla.com>
Sat, 28 Feb 2009 11:59:47 +0100
changeset 23596 69549aec001c3de131785a3b0f76eb30587026e9
parent 23595 fc5fe8d3d743320f598287cd2b8a223ea9bc16bb
child 23597 ebfcc75389af80ec3e9473c0cc5ea5a10101c4d7
push id814
push usermak77@bonardo.net
push dateSat, 28 Feb 2009 11:03:08 +0000
reviewersdietrich, blocking191
bugs479384
milestone1.9.1b3pre
Bug 479384 - Reset button in Library search box is broken, r=dietrich, a=blocking191
browser/components/places/content/places.js
--- a/browser/components/places/content/places.js
+++ b/browser/components/places/content/places.js
@@ -201,22 +201,16 @@ var PlacesOrganizer = {
    */
   _cachedLeftPaneSelectedNode: null,
   onPlaceSelected: function PO_onPlaceSelected(resetSearchBox) {
     // Don't change the right-hand pane contents when there's no selection
     if (!this._places.hasSelection)
       return;
 
     var node = this._places.selectedNode;
-    // When we invalidate a container we use suppressSelectionEvent, when it is
-    // unset a select event is fired, in many cases the selection did not really
-    // change, so we should check for it, and return early in such a case.
-    if (node == this._cachedLeftPaneSelectedNode)
-      return;
-    this._cachedLeftPaneSelectedNode = node;
     var queries = asQuery(node).getQueries({});
 
     // Items are only excluded on the left pane
     var options = node.queryOptions.clone();
     options.excludeItems = false;
     var placeURI = PlacesUtils.history.queriesToQueryString(queries, queries.length, options);
 
     // Update the right-pane contents.
@@ -226,16 +220,27 @@ var PlacesOrganizer = {
       this._content.place = placeURI;
 
       // Update the back/forward buttons.
       this.location = node.uri;
     }
 
     // Make sure the search UI is hidden.
     PlacesSearchBox.hideSearchUI();
+
+    // When we invalidate a container we use suppressSelectionEvent, when it is
+    // unset a select event is fired, in many cases the selection did not really
+    // change, so we should check for it, and return early in such a case. Note
+    // that we cannot return any earlier than this point, because when
+    // !resetSearchBox, we need to update location and hide the UI as above,
+    // even though the selection has not changed.
+    if (node == this._cachedLeftPaneSelectedNode)
+      return;
+    this._cachedLeftPaneSelectedNode = node;
+
     if (resetSearchBox)
       PlacesSearchBox.searchFilter.reset();
 
     this._setSearchScopeForNode(node);
     if (this._places.treeBoxObject.focused)
       this._fillDetailsPane([node]);
   },