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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/md_bookmarks/folder_node.js
diff --git a/chrome/browser/resources/md_bookmarks/folder_node.js b/chrome/browser/resources/md_bookmarks/folder_node.js
index 94cc5e7a665fea47fdf550a04549d56e42d91e4c..68dd8fa07a3eb0deb47202a202e6d752ce47df40 100644
--- a/chrome/browser/resources/md_bookmarks/folder_node.js
+++ b/chrome/browser/resources/md_bookmarks/folder_node.js
@@ -85,11 +85,33 @@ Polymer({
onKeydown_: function(e) {
var direction = 0;
var handled = true;
- // TODO(calamity): Handle left/right arrow keys.
if (e.key == 'ArrowUp') {
direction = -1;
} else if (e.key == 'ArrowDown') {
direction = 1;
+ } 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.
+ // The right arrow opens a folder if closed and goes to the first child
+ // otherwise.
+ if (this.hasChildFolder_()) {
+ if (this.isClosed_) {
+ this.dispatch(
+ bookmarks.actions.changeFolderOpen(this.item_.id, true));
+ } else {
+ direction = 1;
+ }
+ }
+ } else if (e.key == 'ArrowLeft') {
+ // The left arrow closes a folder if open and goes to the parent
+ // otherwise.
+ if (this.hasChildFolder_() && !this.isClosed_) {
+ this.dispatch(bookmarks.actions.changeFolderOpen(this.item_.id, false));
+ } else {
+ var parentFolderNode = this.getParentFolderNode_();
+ if (parentFolderNode.itemId != ROOT_NODE_ID) {
+ parentFolderNode.selectFolder_();
+ parentFolderNode.getFocusTarget().focus();
+ }
+ }
} else {
handled = false;
}

Powered by Google App Engine
This is Rietveld 408576698