Commit d263cf26 authored by tommycli's avatar tommycli Committed by Commit bot

MD Settings: Don't auto-close navigable dialogs on popstate.

Previously, we made all cr-dialogs close on popstate. This is good,
except for navigable dialogs.

For navigable dialogs: It should open if the new route is the dialog's
route, and close otherwise. All the navigable dialogs already have code
that implements this behavior, but it conflicts with the popstate
event handler on cr-dialog.

This CL adds a parameter that disables this behavior for navigable
dialogs.

BUG=656918
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation

Review-Url: https://codereview.chromium.org/2445713004
Cr-Commit-Position: refs/heads/master@{#427249}
parent 9811dce8
......@@ -110,7 +110,7 @@
}
</style>
<dialog is="cr-dialog" id="dialog">
<dialog is="cr-dialog" id="dialog" ignore-popstate>
<div class="title">$i18n{clearBrowsingData}</div>
<div class="body">
<div class="row">
......
......@@ -314,7 +314,8 @@
</if>
</settings-animated-pages>
<dialog is="cr-dialog" id="disconnectDialog" on-close="onDisconnectClosed_">
<dialog is="cr-dialog" id="disconnectDialog" on-close="onDisconnectClosed_"
ignore-popstate>
<div class="title">$i18n{syncDisconnectTitle}</div>
<div class="body">
<div inner-h-t-m-l="[[getDisconnectExplanationHtml_(syncStatus.domain)]]">
......
......@@ -23,7 +23,7 @@
margin: 0 8px;
}
</style>
<dialog is="cr-dialog" id="dialog">
<dialog is="cr-dialog" id="dialog" ignore-popstate>
<div class="title">
[[getPageTitle_(isTriggered_, triggeredResetToolName_)]]
</div>
......
......@@ -15,12 +15,23 @@ Polymer({
is: 'cr-dialog',
extends: 'dialog',
properties: {
/**
* True if the dialog should remain open on 'popstate' events. This is used
* for navigable dialogs that have their separate navigation handling code.
*/
ignorePopstate: {
type: Boolean,
value: false,
},
},
/** @override */
created: function() {
ready: function() {
// If the active history entry changes (i.e. user clicks back button),
// all open dialogs should be cancelled.
window.addEventListener('popstate', function() {
if (this.open)
if (!this.ignorePopstate && this.open)
this.cancel();
}.bind(this));
},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment