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

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

Issue 2708863004: WebUI: Close cr-action-menu on popstate event. (Closed)
Patch Set: Add test Created 3 years, 10 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_action_menu_test.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_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 24e54ba11419875e6fd2b8cfb423ebf602f8aed7..9f58dc4f6cd9079f59c2ee05364b0f1f5aef5e46 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
@@ -20,11 +20,11 @@ Polymer({
anchorElement_: null,
/**
- * Reference to the bound window's resize listener, such that it can be
- * removed on detach.
+ * Bound reference to an event listener function such that it can be removed
+ * on detach.
* @private {?Function}
*/
- onWindowResize_: null,
+ boundClose_: null,
hostAttributes: {
tabindex: 0,
@@ -42,12 +42,13 @@ Polymer({
/** override */
detached: function() {
- this.removeResizeListener_();
+ this.removeListeners_();
},
/** @private */
- removeResizeListener_: function() {
- window.removeEventListener('resize', this.onWindowResize_);
+ removeListeners_: function() {
+ window.removeEventListener('resize', this.boundClose_);
+ window.removeEventListener('popstate', this.boundClose_);
},
/**
@@ -111,8 +112,8 @@ Polymer({
/** @override */
close: function() {
- // Removing 'resize' listener when dialog is closed.
- this.removeResizeListener_();
+ // Removing 'resize' and 'popstate' listeners when dialog is closed.
+ this.removeListeners_();
HTMLDialogElement.prototype.close.call(this);
this.anchorElement_.focus();
this.anchorElement_ = null;
@@ -124,11 +125,12 @@ Polymer({
*/
showAt: function(anchorElement) {
this.anchorElement_ = anchorElement;
- this.onWindowResize_ = this.onWindowResize_ || function() {
+ this.boundClose_ = this.boundClose_ || function() {
if (this.open)
this.close();
}.bind(this);
- window.addEventListener('resize', this.onWindowResize_);
+ window.addEventListener('resize', this.boundClose_);
+ window.addEventListener('popstate', this.boundClose_);
// Reset position to prevent previous values from affecting layout.
this.style.left = '';
« no previous file with comments | « chrome/test/data/webui/cr_elements/cr_action_menu_test.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698