| 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..05346b3e73c10a95b04d027ddccfd0fd84598a1a 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_',
|
| },
|
|
|
| @@ -83,6 +84,27 @@ Polymer({
|
| e.preventDefault();
|
| },
|
|
|
| + debounceFlusher_: null,
|
| +
|
| + onMouseMove_: function(e) {
|
| + var target = e.target;
|
| +
|
| + if (!this.debounceFlusher_) {
|
| + this.debounceFlusher_ = setTimeout(function() {
|
| + this.flushDebouncer('cr-action-menu-mousemove');
|
| + this.debounceFlusher_ = null;
|
| + }.bind(this), 10);
|
| + }
|
| +
|
| + this.debounce('cr-action-menu-mousemove', function() {
|
| + if (target.classList.contains('dropdown-item') &&
|
| + target != document.activeElement)
|
| + target.focus();
|
| + else
|
| + this.focus(); // Blur option focus but keep up/down button working.
|
| + }.bind(this), 10);
|
| + },
|
| +
|
| /**
|
| * @param {number} step -1 for getting previous option (up), 1 for getting
|
| * next option (down).
|
| @@ -99,6 +121,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];
|
|
|