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

Unified Diff: ui/webui/resources/cr_elements/cr_shared_menu/cr_shared_menu.js

Issue 2202133002: MD WebUI: Do not restore focus from <cr-shared-menu> when closing with tap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 | « chrome/test/data/webui/cr_elements/cr_shared_menu_tests.js ('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_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;
+ },
});
« no previous file with comments | « chrome/test/data/webui/cr_elements/cr_shared_menu_tests.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698