diff --git a/addons/web_editor/static/lib/odoo-editor/src/utils/utils.js b/addons/web_editor/static/lib/odoo-editor/src/utils/utils.js index f954708cef6..a79bb581e07 100644 --- a/addons/web_editor/static/lib/odoo-editor/src/utils/utils.js +++ b/addons/web_editor/static/lib/odoo-editor/src/utils/utils.js @@ -962,13 +962,8 @@ export function isUnremovable(node) { if (node.nodeType !== Node.ELEMENT_NODE && node.nodeType !== Node.TEXT_NODE) { return true; } - const isEditableRoot = - node.isContentEditable && - node.parentElement && - !node.parentElement.isContentEditable && - node.nodeName !== 'A'; // links can be their own contenteditable but should be removable by default. return ( - isEditableRoot || + node.oid === 'root' || (node.nodeType === Node.ELEMENT_NODE && (node.getAttribute('t-set') || node.getAttribute('t-call'))) || (node.classList && node.classList.contains('oe_unremovable')) diff --git a/addons/web_editor/static/lib/odoo-editor/test/spec/editor.test.js b/addons/web_editor/static/lib/odoo-editor/test/spec/editor.test.js index 2f0d75a9135..bc314d21d91 100644 --- a/addons/web_editor/static/lib/odoo-editor/test/spec/editor.test.js +++ b/addons/web_editor/static/lib/odoo-editor/test/spec/editor.test.js @@ -2246,6 +2246,24 @@ X[] }); }); + describe('deleterange', () => { + it('should remove element which is contenteditable=true even if their parent is contenteditable=false', async () => { + await testEditor(BasicEditor, { + contentBefore: unformat(` +
before[o
+intruder
o]after
`), + stepFunction: async editor => { + await deleteBackward(editor); + }, + contentAfter: unformat(` +before[]after
`), + }); + }); + }); + describe('insertParagraphBreak', () => { describe('Selection collapsed', () => { describe('Basic', () => {