| Index: ui/webui/resources/cr_elements/cr_shared_menu/cr_shared_menu.js
|
| diff --git a/ui/webui/resources/cr_elements/cr_shared_menu/cr_shared_menu.js b/ui/webui/resources/cr_elements/cr_shared_menu/cr_shared_menu.js
|
| index 7dfdd31faec7d90d477a53a60744874007deaca1..b4f4003dd7cfc924f0107a816fdbebf266a7d408 100644
|
| --- a/ui/webui/resources/cr_elements/cr_shared_menu/cr_shared_menu.js
|
| +++ b/ui/webui/resources/cr_elements/cr_shared_menu/cr_shared_menu.js
|
| @@ -92,6 +92,10 @@ Polymer({
|
| 'tab': 'onTabPressed_',
|
| },
|
|
|
| + listeners: {
|
| + 'dropdown.iron-overlay-canceled': 'onOverlayCanceled_',
|
| + },
|
| +
|
| /**
|
| * The last anchor that was used to open a menu. It's necessary for toggling.
|
| * @private {?Element}
|
| @@ -134,6 +138,7 @@ Polymer({
|
| openMenu: function(anchor, itemData) {
|
| this.itemData = itemData;
|
| this.lastAnchor_ = anchor;
|
| + this.$.dropdown.restoreFocusOnClose = true;
|
|
|
| var focusableChildren = Polymer.dom(this).querySelectorAll(
|
| '[tabindex]:not([hidden]),button:not([hidden])');
|
| @@ -194,4 +199,15 @@ Polymer({
|
| if (!this.menuOpen)
|
| this.itemData = null;
|
| },
|
| +
|
| + /**
|
| + * Prevent focus restoring when tapping outside the menu. This stops the
|
| + * focus moving around unexpectedly when closing the menu with the mouse.
|
| + * @param {CustomEvent} e
|
| + * @private
|
| + */
|
| + onOverlayCanceled_: function(e) {
|
| + if (e.detail.type == 'tap')
|
| + this.$.dropdown.restoreFocusOnClose = false;
|
| + },
|
| });
|
|
|