Index: ui/file_manager/file_manager/foreground/js/ui/navigation_list.js |
diff --git a/ui/file_manager/file_manager/foreground/js/ui/navigation_list.js b/ui/file_manager/file_manager/foreground/js/ui/navigation_list.js |
index 22bad9adcf500c7bdf57a20755cc07cbde6d8b25..4368c9bef67dde49ab94587971f2ae3dc2874e9e 100644 |
--- a/ui/file_manager/file_manager/foreground/js/ui/navigation_list.js |
+++ b/ui/file_manager/file_manager/foreground/js/ui/navigation_list.js |
@@ -201,9 +201,6 @@ |
this.scrollBar_ = new ScrollBar(); |
this.scrollBar_.initialize(this.parentNode, this); |
- // Keeps track of selected model item to detect if it is changed actually. |
- this.currentModelItem_ = null; |
- |
// Overriding default role 'list' set by cr.ui.List.decorate() to 'listbox' |
// role for better accessibility on ChromeOS. |
this.setAttribute('role', 'listbox'); |
@@ -290,7 +287,6 @@ |
if (index < 0 || index > this.dataModel.length - 1) |
return false; |
- this.selectionModel.selectedIndex = index; |
this.activateModelItem_(this.dataModel.item(index)); |
return true; |
}; |
@@ -303,11 +299,16 @@ |
*/ |
NavigationList.prototype.activateModelItem_ = function(modelItem) { |
var onEntryResolved = function(entry) { |
- // Change directory to the model item's root directory if needed. |
- if (!util.isSameEntry(this.directoryModel_.getCurrentDirEntry(), entry)) { |
- metrics.recordUserAction('FolderShortcut.Navigate'); |
- this.directoryModel_.changeDirectoryEntry(entry); |
+ // If the root item of active directory was same as newly activated |
+ // root item, keep the active directory as it was. |
+ var currentDir = this.directoryModel_.getCurrentDirEntry(); |
+ if (util.isSameEntry(entry, currentDir) || |
+ util.isDescendantEntry(entry, currentDir)) { |
+ return; |
} |
+ |
+ metrics.recordUserAction('FolderShortcut.Navigate'); |
+ this.directoryModel_.changeDirectoryEntry(entry); |
}.bind(this); |
if (modelItem.isVolume) { |
@@ -349,25 +350,12 @@ |
* @private |
*/ |
NavigationList.prototype.onSelectionChange_ = function(event) { |
- var index = this.selectionModel.selectedIndex; |
- if (index < 0 || index > this.dataModel.length - 1) |
- return; |
- |
- // If the selected model item is not changed actually, we don't change the |
- // current directory even if the selected index is changed. |
- var modelItem = this.dataModel.item(index); |
- if (modelItem === this.currentModelItem_) |
- return; |
- |
- // Remember the selected model item. |
- this.currentModelItem_ = modelItem; |
- |
// This handler is invoked even when the navigation list itself changes the |
// selection. In such case, we shouldn't handle the event. |
if (this.dontHandleSelectionEvent_) |
return; |
- this.activateModelItem_(modelItem); |
+ this.selectByIndex(this.selectionModel.selectedIndex); |
}; |
/** |