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

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: Merge branch 'iron-test-helpers' into hover-menu 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..0a107e79e8f16e3a8bc3e698b6b65ac6feecac63 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_',
+ 'mousemove': 'onMouseMove_',
'tap': 'onTap_',
},
@@ -84,6 +85,21 @@ Polymer({
},
/**
+ * @param {!MouseEvent} e
+ * @private
+ */
+ onMouseMove_: function(e) {
+ var target = e.target;
Dan Beam 2017/04/05 03:29:21 i'm still a little confused. I don't think this i
scottchen 2017/04/05 20:56:31 Acknowledged the concern, I've modified the code t
+
+ if (target.classList.contains('dropdown-item') &&
Dan Beam 2017/04/04 23:41:13 does this move if you move the mouse inside of a <
scottchen 2017/04/04 23:48:45 yes, it focuses the checkbox (ripple shown around
Dan Beam 2017/04/04 23:49:59 don't you actually want it to focus the item, not
scottchen 2017/04/05 00:08:19 The top-most item *is* the <paper-checkbox>, which
Dan Beam 2017/04/05 03:29:21 ok
+ target != document.activeElement) {
+ target.focus();
+ } else {
+ this.focus(); // Blur option focus but keep up/down button working.
Dan Beam 2017/04/05 03:29:21 why is this needed? keydown should be fine as lon
scottchen 2017/04/05 20:56:31 It's more about blurring the option focus. The com
scottchen 2017/04/05 20:58:10 Also (noting for other readers) we discussed offli
+ }
+ },
+
+ /**
* @param {number} step -1 for getting previous option (up), 1 for getting
* next option (down).
* @return {?Element} The next focusable option, taking into account
@@ -99,6 +115,10 @@ Polymer({
var focusedIndex =
Array.prototype.indexOf.call(this.options_, this.root.activeElement);
+ // Avoid off-by-one when nothing is focused and up is pressed.
+ if (focusedIndex === -1 && step === -1)
+ focusedIndex = 0;
+
do {
focusedIndex = (numOptions + focusedIndex + step) % numOptions;
nextOption = this.options_[focusedIndex];

Powered by Google App Engine
This is Rietveld 408576698