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

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: add missing import 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 | « ui/webui/resources/cr_elements/cr_action_menu/cr_action_menu.html ('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..c68aece64c28995c68bcd39c461cc52c496d20ba 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
@@ -26,12 +26,16 @@ Polymer({
*/
boundClose_: null,
+ /** @private {boolean} */
+ hasMousemoveListener_: false,
+
hostAttributes: {
tabindex: 0,
},
listeners: {
'keydown': 'onKeyDown_',
+ 'mouseover': 'onMouseover_',
'tap': 'onTap_',
},
@@ -77,13 +81,41 @@ Polymer({
return;
var nextOption = this.getNextOption_(e.key == 'ArrowDown' ? 1 : -1);
- if (nextOption)
+ if (nextOption) {
+ if (!this.hasMousemoveListener_) {
+ this.hasMousemoveListener_ = true;
+ listenOnce(this, 'mousemove', function(e) {
+ this.onMouseover_(e);
+ this.hasMousemoveListener_ = false;
+ }.bind(this));
+ }
nextOption.focus();
+ }
e.preventDefault();
},
/**
+ * @param {!Event} e
+ * @private
+ */
+ onMouseover_: function(e) {
+ // TODO(scottchen): Using "focus" to determine selected item might mess
+ // with screen readers in some edge cases.
+ var i = 0;
+ do {
+ var target = e.path[i++];
+ if (target.classList && target.classList.contains('dropdown-item')) {
+ target.focus();
+ return;
+ }
+ } while (this != target);
+
+ // 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 | « ui/webui/resources/cr_elements/cr_action_menu/cr_action_menu.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698