From a0a184fdf67648007e252790593baeea0616bcca Mon Sep 17 00:00:00 2001 From: Younn Olivier Date: Thu, 18 Aug 2022 09:10:16 +0000 Subject: [PATCH] [FIX] web_editor, website: update invisible elements panel on undo Before this commit, after: - Drop a popup, - Click on the undo button, => The invisible elements panel was still displayed, with the popup entry. To fix that, the panel visibility is updated on the 'historyUndo'/'historyRedo' events alongside refreshing the snippets editors. task-2687506 closes odoo/odoo#98807 X-original-commit: 76704f47db46ac7e71a894f620d8061a3eb594a7 Signed-off-by: Quentin Smetz (qsm) --- .../static/src/js/editor/snippets.editor.js | 2 ++ .../tests/tours/snippet_popup_add_remove.js | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+) 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 997ba0d11a7..3ac46c358b7 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -1440,6 +1440,8 @@ var SnippetsMenu = Widget.extend({ const target = selection.getRangeAt(0).startContainer.parentElement; this._activateSnippet($(target)); } + + this._updateInvisibleDOM(); }, 500); this.options.wysiwyg.odooEditor.addEventListener('historyUndo', refreshSnippetEditors); this.options.wysiwyg.odooEditor.addEventListener('historyRedo', refreshSnippetEditors); diff --git a/addons/website/static/tests/tours/snippet_popup_add_remove.js b/addons/website/static/tests/tours/snippet_popup_add_remove.js index f8194f30e95..e0d86271b9f 100644 --- a/addons/website/static/tests/tours/snippet_popup_add_remove.js +++ b/addons/website/static/tests/tours/snippet_popup_add_remove.js @@ -28,4 +28,28 @@ wTourUtils.registerEditionTour('snippet_popup_add_remove', { in_modal: false, trigger: 'iframe #wrap.o_editable:not(:has([data-snippet="s_popup"]))', run: () => null, +}, +// Test that undoing dropping the snippet removes the invisible elements panel. +{ + content: "Drop the snippet again.", + trigger: '#oe_snippets .oe_snippet:has(> [data-snippet="s_popup"]) .oe_snippet_thumbnail', + run: "drag_and_drop iframe #wrap", +}, { + content: "The popup should be in the invisible elements panel.", + in_modal: false, + trigger: '.o_we_invisible_el_panel .o_we_invisible_entry', + run: () => null, // It's a check. +}, { + content: "Click on the 'undo' button.", + in_modal: false, + trigger: '#oe_snippets button[data-action="undo"]', +}, { + content: "Check that the s_popup was removed.", + in_modal: false, + trigger: 'iframe #wrap.o_editable:not(:has([data-snippet="s_popup"]))', + run: () => null, // It's a check. +}, { + content: "The invisible elements panel should also be removed.", + trigger: '#oe_snippets:has(.o_we_invisible_el_panel.d-none)', + run: () => null, // It's a check. }]);