Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(421)

Side by Side Diff: chrome/browser/resources/md_bookmarks/folder_node.js

Issue 2857893002: [MD Bookmarks] Allow left/right keys to close/open folders in sidebar. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 Polymer({ 5 Polymer({
6 is: 'bookmarks-folder-node', 6 is: 'bookmarks-folder-node',
7 7
8 behaviors: [ 8 behaviors: [
9 bookmarks.StoreClient, 9 bookmarks.StoreClient,
10 ], 10 ],
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 return this.depth == 0; 78 return this.depth == 0;
79 }, 79 },
80 80
81 /** 81 /**
82 * @private 82 * @private
83 * @param {!Event} e 83 * @param {!Event} e
84 */ 84 */
85 onKeydown_: function(e) { 85 onKeydown_: function(e) {
86 var direction = 0; 86 var direction = 0;
87 var handled = true; 87 var handled = true;
88 // TODO(calamity): Handle left/right arrow keys.
89 if (e.key == 'ArrowUp') { 88 if (e.key == 'ArrowUp') {
90 direction = -1; 89 direction = -1;
91 } else if (e.key == 'ArrowDown') { 90 } else if (e.key == 'ArrowDown') {
92 direction = 1; 91 direction = 1;
92 } else if (e.key == 'ArrowRight') {
tsergeant 2017/05/05 01:31:07 These shortcuts need to flip in RTL.
calamity 2017/05/09 03:45:35 Done.
93 // The right arrow opens a folder if closed and goes to the first child
94 // otherwise.
95 if (this.hasChildFolder_()) {
96 if (this.isClosed_) {
97 this.dispatch(
98 bookmarks.actions.changeFolderOpen(this.item_.id, true));
99 } else {
100 direction = 1;
101 }
102 }
103 } else if (e.key == 'ArrowLeft') {
104 // The left arrow closes a folder if open and goes to the parent
105 // otherwise.
106 if (this.hasChildFolder_() && !this.isClosed_) {
107 this.dispatch(bookmarks.actions.changeFolderOpen(this.item_.id, false));
108 } else {
109 var parentFolderNode = this.getParentFolderNode_();
110 if (parentFolderNode.itemId != ROOT_NODE_ID) {
111 parentFolderNode.selectFolder_();
112 parentFolderNode.getFocusTarget().focus();
113 }
114 }
93 } else { 115 } else {
94 handled = false; 116 handled = false;
95 } 117 }
96 118
97 if (direction) 119 if (direction)
98 this.changeKeyboardSelection_(direction, this.root.activeElement); 120 this.changeKeyboardSelection_(direction, this.root.activeElement);
99 121
100 if (!handled) 122 if (!handled)
101 return; 123 return;
102 124
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 }, 314 },
293 315
294 /** 316 /**
295 * @private 317 * @private
296 * @return {string} 318 * @return {string}
297 */ 319 */
298 getTabIndex_: function() { 320 getTabIndex_: function() {
299 return this.isSelectedFolder_ ? '0' : ''; 321 return this.isSelectedFolder_ ? '0' : '';
300 }, 322 },
301 }); 323 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698