From 4c1d7fec8207f2fffc4a146e86107220ee107ca3 Mon Sep 17 00:00:00 2001 From: "Guillaume (gdi)" Date: Fri, 25 Aug 2023 06:29:20 +0000 Subject: [PATCH] [FIX] web_editor: don't display option if target matches data-exclude Since [this commit], it's now possible to edit a media when it's in a parent that is not editable thanks to `o_editable_media` class. Unfortunately, these changes make the new class bypass the potential `data-exclude` defined in the XML option declaration. So if the target looks like that: ```html ``` and the XML option declaration has a `data-exclude=".odoo"`, the option will still be displayed. This commit corrects the way the `o_editable_media` class works, so that it only bypasses the `.o_not_editable` but not the entire exclude. [this commit]: https://github.com/odoo/odoo/commit/580f1b77ce0b96b7efbf83a0ccdf6979bbf0e904 task-3476644 closes odoo/odoo#133663 X-original-commit: f73734557116a348ac14b2724e1380546192ca12 Signed-off-by: Quentin Smetz (qsm) Signed-off-by: Guillaume Dieleman (gdi) --- .../static/src/js/editor/snippets.editor.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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 b3630e4a2f5..9059f6945cd 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -2772,16 +2772,19 @@ var SnippetsMenu = Widget.extend({ // Without the `:not(.s_social_media)`, it is no longer possible to edit // icons in the social media snippet. This should be fixed in a more // proper way to get rid of this hack. - exclude += `${exclude && ', '}.o_snippet_not_selectable, .o_not_editable:not(.s_social_media) :not([contenteditable="true"])`; + exclude += `${exclude && ', '}.o_snippet_not_selectable`; let filterFunc = function () { - if (!$(this).is(exclude)) { - return true; + // Exclude what it is asked to exclude. + if ($(this).is(exclude)) { + return false; } + // `o_editable_media` bypasses the `o_not_editable` class. if (this.classList.contains('o_editable_media')) { return weUtils.shouldEditableMediaBeEditable(this); } - return false; + return !$(this) + .is('.o_not_editable:not(.s_social_media) :not([contenteditable="true"])'); }; if (target) { const oldFilter = filterFunc;