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

Unified Diff: ui/webui/resources/cr_elements/cr_action_menu/cr_action_menu.js

Issue 2801453002: MD Settings: mouse movements should focus cr-action-menu items (Closed)
Patch Set: updates based on comments Created 3 years, 8 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
« no previous file with comments | « chrome/test/data/webui/cr_elements/cr_action_menu_test.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/webui/resources/cr_elements/cr_action_menu/cr_action_menu.js
diff --git a/ui/webui/resources/cr_elements/cr_action_menu/cr_action_menu.js b/ui/webui/resources/cr_elements/cr_action_menu/cr_action_menu.js
index 9f58dc4f6cd9079f59c2ee05364b0f1f5aef5e46..1db658c94145dd1b8139b106e457e659cf9125c9 100644
--- a/ui/webui/resources/cr_elements/cr_action_menu/cr_action_menu.js
+++ b/ui/webui/resources/cr_elements/cr_action_menu/cr_action_menu.js
@@ -32,6 +32,7 @@ Polymer({
listeners: {
'keydown': 'onKeyDown_',
+ 'mouseover': 'onMouseover_',
'tap': 'onTap_',
},
@@ -73,6 +74,8 @@ Polymer({
return;
}
+ listenOnce(this, 'mousemove', this.onMouseover_.bind(this));
dpapad 2017/04/06 00:06:02 We are leaking mousemove listeners. When the user
Dan Beam 2017/04/06 00:08:35 sure, that makes sense
scottchen 2017/04/06 00:44:33 Done.
+
if (e.key !== 'ArrowDown' && e.key !== 'ArrowUp')
return;
@@ -84,6 +87,25 @@ Polymer({
},
/**
+ * @param {!MouseEvent} e
+ * @private
+ */
+ onMouseover_: function(e) {
+ // TODO(scottchen): Using "focus" to determine selected item might mess
+ // with screen readers in some edge cases.
+ var target = e.path[0];
+ for (var i = 0; this != target; target = e.path[i++]) {
Dan Beam 2017/04/05 23:42:30 nit: var i = 0; for (var target; this != target;
scottchen 2017/04/06 00:44:33 I changed it to a do-while for readability.
+ if (target.classList && target.classList.contains('dropdown-item')) {
+ target.focus();
+ return;
+ }
+ };
+
+ // The user moved the mouse off the options. Reset focus to the dialog.
+ this.focus();
+ },
+
+ /**
* @param {number} step -1 for getting previous option (up), 1 for getting
* next option (down).
* @return {?Element} The next focusable option, taking into account
« no previous file with comments | « chrome/test/data/webui/cr_elements/cr_action_menu_test.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698