From bfac8b6346b8f158f01a495a77f7fc7ef5983b63 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Thu, 2 Jul 2015 09:35:52 +0200 Subject: [PATCH] [FIX] mail: discard changes confirm dialog This change is required for new design compatibility because when toggling the app switcher, the whole content is detached. The app switcher is toggled once the deferred def is resolved. If def is resolved before the dialog is closed, the dialog is detached as well, and re-attached when clicking on another apps. With this rev., def is resolved once the dialog is closed. Also fixes the on_cancel() call which wasn't done at the right place. --- addons/mail/static/src/js/mail.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index e246c504119..f6a7093c246 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -1051,13 +1051,17 @@ var ComposeMessage = Attachment.extend ({ core.bus.on('clear_uncommitted_changes', this, function (chain_callbacks) { if (this.show_composer) { + var self = this; chain_callbacks(function() { var def = $.Deferred(); var message = _t("You are currently composing a message, your message will be discarded. Are you sure you want to leave this page ?"); var options = { title: _t("Warning"), confirm_callback: function() { - def.resolve(); + self.on_cancel(); + this.on('closed', null, function() { // 'this' is the dialog widget + def.resolve(); + }); }, cancel_callback: function() { def.reject(); @@ -1066,8 +1070,6 @@ var ComposeMessage = Attachment.extend ({ Dialog.confirm(this, message, options); return def; }); - } else { - this.on_cancel(); } }); },