diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/src/commands/enter.js b/addons/web_editor/static/src/js/editor/odoo-editor/src/commands/enter.js index 0f6305bc60e..d894a421409 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/src/commands/enter.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/src/commands/enter.js @@ -91,8 +91,9 @@ HTMLElement.prototype.oEnter = function (offset, firstSplit = true) { */ HTMLHeadingElement.prototype.oEnter = function () { const newEl = HTMLElement.prototype.oEnter.call(this, ...arguments); - if (!newEl.textContent) { + if ([...newEl.textContent].every(char => char === '\u200B')) { // empty or all invisible const node = setTagName(newEl, 'P'); + node.replaceChildren(document.createElement('br')); setCursorStart(node); } }; diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/editor.test.js b/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/editor.test.js index 42259836a9b..25f23bd8d56 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/editor.test.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/editor.test.js @@ -3389,13 +3389,20 @@ X[] }); }); describe('POC extra tests', () => { - it('should duplicate an empty h1', async () => { + it('should insert a paragraph after an empty h1', async () => { await testEditor(BasicEditor, { contentBefore: '
[]
[]