[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 <img class="o_editable_media odoo"/> ``` 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) <qsm@odoo.com> Signed-off-by: Guillaume Dieleman (gdi) <gdi@odoo.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user