From d1e5e4420a841e168fb41c3cba82de9df00f5ea0 Mon Sep 17 00:00:00 2001 From: xO-Tx Date: Fri, 17 Feb 2023 11:21:11 +0000 Subject: [PATCH] [FIX] web_editor: prevent editor rollback of top menu To reproduce the issue: - Website > Add menu items to activate the "+" dropdown. - Edit mode > The top menu disappears. On `_activateContenteditable()`, The `initAutoMoreMenu` > `_adapt()` mutations (changes to move the overflowing menu items to a "+" dropdown) are recorded and rollbacked by the editor, leading to reset the top menu to the step before removing the `.o_menu_loading` class. Recording the `initAutoMoreMenu` mutations leads to some other issues: On edit mode (without overflowing items): - Website > Edit mode > The editor starts (before any updates) with an extra "history step". - Undo > The top menu disappears. On edit mode (with "Mega Menu" items): - Website > Edit mode > Edit text in a "Mega Menu" item > The top menu disappears. The goal of this commit is to fix this behaviour using the `renderingClasses` filter (added in [1]) to prevent the `o_menu_loading` class from being taken into account in the `filterMutationRecords()`. [1]: The https://github.com/odoo/odoo/commit/1c25ddb42393b136cac2a0ee0b9b7280fd803e7d opw-3146873 closes odoo/odoo#113016 X-original-commit: 96c9ebd26aabc3f99acf5d586746b05db7cf4953 Signed-off-by: David Monjoie (dmo) --- addons/web_editor/static/src/js/wysiwyg/wysiwyg.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index 9df99e6df25..e30dc4941ad 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -219,7 +219,7 @@ const Wysiwyg = Widget.extend({ plugins: options.editorPlugins, direction: options.direction || localization.direction || 'ltr', collaborationClientAvatarUrl: `${browser.location.origin}/web/image?model=res.users&field=avatar_128&id=${this.getSession().uid}`, - renderingClasses: ['o_dirty', 'o_transform_removal', 'oe_edited_link'], + renderingClasses: ['o_dirty', 'o_transform_removal', 'oe_edited_link', 'o_menu_loading'], dropImageAsAttachment: options.dropImageAsAttachment, }, editorCollaborationOptions));