Index: chrome/browser/resources/file_manager/js/file_manager.js |
diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js |
index 8ae8d9d4e2a7536dcab3d66df1b1054e5d896c92..bc670e0b04cb6de14419932ae7becb483a145b01 100644 |
--- a/chrome/browser/resources/file_manager/js/file_manager.js |
+++ b/chrome/browser/resources/file_manager/js/file_manager.js |
@@ -1049,6 +1049,8 @@ DialogType.isModal = function(type) { |
this.searchBox_ = this.dialogDom_.querySelector('#search-box'); |
this.searchBox_.addEventListener( |
'input', this.onSearchBoxUpdate_.bind(this)); |
+ this.searchBox_.addEventListener( |
+ 'keydown', this.onSearchBoxKeyDown_.bind(this)); |
this.searchTextMeasure_ = new TextMeasure(this.searchBox_); |
if (util.platform.newUI()) { |
this.searchIcon_ = this.dialogDom_.querySelector('#search-icon'); |
@@ -3498,7 +3500,7 @@ DialogType.isModal = function(type) { |
/** |
* Invoked when the search box is changed. |
* |
- * @param {Event} event The 'changed' event. |
+ * @param {Event} event The changed event. |
* @private |
*/ |
FileManager.prototype.onSearchBoxUpdate_ = function(event) { |
@@ -3523,6 +3525,25 @@ DialogType.isModal = function(type) { |
}; |
/** |
+ * Handles special keys such as Escape on the search box. |
+ * |
+ * @param {Event} event The keydown event. |
+ * @private |
+ */ |
+ FileManager.prototype.onSearchBoxKeyDown_ = function(event) { |
+ // Handle only Esc key now. |
+ if (event.keyCode != 27) return; |
+ if (this.searchBox_.value) return; |
+ var currentList = this.listType_ == FileManager.ListType.DETAIL ? |
+ this.table_.list : this.grid_; |
+ currentList.focus(); |
+ if (currentList.dataModel.length != 0 && |
+ currentList.selectionModel.selectedIndex == -1) { |
+ currentList.selectionModel.selectedIndex = 0; |
+ } |
+ }; |
+ |
+ /** |
* Updates search box's CSS classes. |
* These classes are refered from CSS. |
* |