Chromium Code Reviews| Index: chrome/browser/resources/md_bookmarks/store.js |
| diff --git a/chrome/browser/resources/md_bookmarks/store.js b/chrome/browser/resources/md_bookmarks/store.js |
| index 90eb8e91399813ddb1b8d1f2b06ae6005a305adf..434f6f61c6394279578d2a955352ca1b603af228 100644 |
| --- a/chrome/browser/resources/md_bookmarks/store.js |
| +++ b/chrome/browser/resources/md_bookmarks/store.js |
| @@ -97,7 +97,6 @@ var BookmarksStore = Polymer({ |
| deselectFolders_: function() { |
| this.unlinkPaths('displayedList'); |
| this.set(this.idToNodeMap_[this.selectedId].path + '.isSelected', false); |
| - this.selectedId = null; |
| }, |
| /** |
| @@ -116,7 +115,10 @@ var BookmarksStore = Polymer({ |
| /** @private */ |
| updateSearchDisplay_: function() { |
| if (!this.searchTerm) { |
| - this.fire('selected-folder-changed', this.rootNode.children[0].id); |
| + var selectedFolder = |
| + this.selectedId ? this.selectedId : this.rootNode.children[0].id; |
| + this.fire('selected-folder-changed', selectedFolder); |
|
tsergeant
2017/01/25 00:23:18
I mentioned this before, but I think now is the ri
angelayang
2017/01/31 02:25:03
Yep all that works
|
| + this.updateSelectedDisplay_(); |
| } else { |
| chrome.bookmarks.search(this.searchTerm, function(results) { |
| if (this.selectedId) |
| @@ -129,10 +131,6 @@ var BookmarksStore = Polymer({ |
| /** @private */ |
| updateSelectedDisplay_: function() { |
| - // Don't change to the selected display if ID was cleared. |
| - if (!this.selectedId) |
| - return; |
| - |
| var selectedNode = this.idToNodeMap_[this.selectedId]; |
| this.linkPaths('displayedList', selectedNode.path + '.children'); |
| this._setDisplayedList(selectedNode.children); |
| @@ -239,7 +237,13 @@ var BookmarksStore = Polymer({ |
| onFolderOpenChanged_: function(e) { |
| var folder = this.idToNodeMap_[e.detail.id]; |
| this.set(folder.path + '.isOpen', e.detail.open); |
| - if (!folder.isOpen && this.isAncestorOfSelected_(folder)) |
| + if (folder.isOpen || !this.isAncestorOfSelected_(folder)) |
| + return; |
| + |
| + // Save the closed folder as the selectedId. |
| + if (this.searchTerm) |
|
angelayang
2017/01/31 02:25:03
This piece of logic reoccurs a few times so i'm go
|
| + this.selectedId = folder.id; |
| + else |
| this.fire('selected-folder-changed', folder.id); |
| }, |
| }); |