From 4292ed0e350e710b529239011e59044e60071d80 Mon Sep 17 00:00:00 2001 From: "Arthur Detroux (ard)" Date: Mon, 27 Jun 2022 07:58:19 +0000 Subject: [PATCH] [FIX] website: re-enable action buttons when canceling discard dialog Steps to reproduce: - Go on website - Click on edit - Add a snippet - Click on discard - Close the popup using the 'X' at the top of the popup - Buttons are still disabled Commit [1] adapted the website dialogs to the OWL Api but also introduced this bug. This commit fixes that behaviour and re-enables the buttons if the popup is closed. [1]: https://github.com/odoo/odoo/commit/31cc10b91dc7762e23b4bde9b945be0c4ce3fe3b task-2687506 Part-of: odoo/odoo#94564 --- .../components/wysiwyg_adapter/wysiwyg_adapter.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/addons/website/static/src/components/wysiwyg_adapter/wysiwyg_adapter.js b/addons/website/static/src/components/wysiwyg_adapter/wysiwyg_adapter.js index 8c2a67a66f6..db28a8c0f74 100644 --- a/addons/website/static/src/components/wysiwyg_adapter/wysiwyg_adapter.js +++ b/addons/website/static/src/components/wysiwyg_adapter/wysiwyg_adapter.js @@ -610,10 +610,19 @@ export class WysiwygAdapterComponent extends ComponentAdapter { */ _onCancelRequest(event) { if (this._isDirty()) { + let discarding = false; this.dialogs.add(WebsiteDialog, { body: _t("If you discard the current edits, all unsaved changes will be lost. You can cancel to return to edit mode."), - primaryClick: () => this.props.quitCallback(), - secondaryClick: event.data.onReject, + primaryClick: () => { + discarding = true; + }, + }, { + onClose: () => { + if (discarding) { + return this.props.quitCallback(); + } + return event.data.onReject(); + } }); } else { return this.props.quitCallback();