diff --git a/addons/web_editor/static/src/js/editor/snippets.editor.js b/addons/web_editor/static/src/js/editor/snippets.editor.js index ab5b0fa07fe..3f936297eff 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -3406,11 +3406,11 @@ var SnippetsMenu = Widget.extend({ * On click on discard button. */ _onDiscardClick: function () { - this._buttonClick(() => { + this._buttonClick(after => { this.snippetEditors.forEach(editor => { editor.toggleOverlay(false); }); - this.trigger_up('request_cancel'); + this.trigger_up('request_cancel', {onReject: after}); }, this.$el[0].querySelector('button[data-action=cancel]')); }, /** @@ -3465,12 +3465,18 @@ var SnippetsMenu = Widget.extend({ return; } this._buttonAction = true; - dom.addButtonLoadingEffect(button); + const removeLoadingEffect = dom.addButtonLoadingEffect(button); const actionButtons = this.$el[0].querySelectorAll('[data-action]'); for (const actionButton of actionButtons) { actionButton.disabled = true; } - await action(); + const after = () => { + removeLoadingEffect(); + for (const actionButton of actionButtons) { + actionButton.disabled = false; + } + }; + await action(after); this._buttonAction = false; }, 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 f449c14fa79..a568713f721 100644 --- a/addons/website/static/src/components/wysiwyg_adapter/wysiwyg_adapter.js +++ b/addons/website/static/src/components/wysiwyg_adapter/wysiwyg_adapter.js @@ -7,6 +7,7 @@ import { useWowlService } from '@web/legacy/utils'; import { useHotkey } from '@web/core/hotkeys/hotkey_hook'; import { EditMenuDialog, MenuDialog } from "../dialog/edit_menu"; +import { WebsiteDialog } from '../dialog/dialog'; import { PageOption } from "./page_options"; const { onWillStart, useEffect } = owl; @@ -559,7 +560,16 @@ export class WysiwygAdapterComponent extends ComponentAdapter { * @private */ _onCancelRequest(event) { - return this.props.quitCallback(); + const isDirty = this.widget.isDirty(); + if (isDirty) { + 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, + }); + } else { + return this.props.quitCallback(); + } } /*** * Starts the widgets inside the dropped snippet.