From 294abae96874465cdc147e6d227ed17597f7e4d6 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Mon, 31 Aug 2015 10:56:13 +0200 Subject: [PATCH] [IMP] web: dialog: wait for button's onclick handler to close When a button in the modal's footer has an onclick handler and closes the modal, the action of closing the modal should wait for the potential deferred returned by the handler. For instance, if an handler performs an asynchronous call and, when resolved, triggers a notification, the notification doesn't reach the webclient if the modal is already closed because the widgets hierarchy is broken. --- addons/web/static/src/js/framework/dialog.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/js/framework/dialog.js b/addons/web/static/src/js/framework/dialog.js index 1aedec82aff..b5e63834614 100644 --- a/addons/web/static/src/js/framework/dialog.js +++ b/addons/web/static/src/js/framework/dialog.js @@ -82,11 +82,12 @@ var Dialog = Widget.extend({ var $b = $(QWeb.render('WidgetButton', { widget : { string: text, node: { attrs: {'class': classes} }}})); $b.prop('disabled', b.disabled); $b.on('click', function(e) { + var click_def; if(b.click) { - b.click.call(self, e); + click_def = b.click.call(self, e); } if(b.close) { - self.close(); + $.when(click_def).always(self.close.bind(self)); } }); self.$footer.append($b);