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

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: move off-by-one fix to another CL 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
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..a8e065db682e77c39cd3f2a1cb2e694e684c8ea7 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,12 @@ Polymer({
return;
}
+ var mouseHandler = function(e) {
+ this.onMouseover_(e);
+ this.removeEventListener('mousemove', mouseHandler);
+ };
+ this.addEventListener('mousemove', mouseHandler);
+
if (e.key !== 'ArrowDown' && e.key !== 'ArrowUp')
return;
@@ -84,6 +91,24 @@ 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.
+ for (var i = 0, el = e.path[0]; this != el; el = e.path[i++]) {
+ if (el.classList && el.classList.contains('dropdown-item')) {
+ el.focus();
+ return;
+ }
+ };
+
+ // Reached dialog, so el is not an option.
+ this.focus(); // Blur option focus but keep up/down button working.
+ },
+
+ /**
* @param {number} step -1 for getting previous option (up), 1 for getting
* next option (down).
* @return {?Element} The next focusable option, taking into account

Powered by Google App Engine
This is Rietveld 408576698