diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/utils.js b/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/utils.js index a61f35975a5..6293c74f913 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/utils.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/utils.js @@ -1119,8 +1119,12 @@ export const formatSelection = (editor, formatName, {applyStyle, formatProps} = // Remove the format on all inline ancestors until a block or an element // with a class that is not related to font size (in case the formatting // comes from the class). - while (parentNode && (!isBlock(parentNode) && (parentNode.classList.length === 0 || - [...parentNode.classList].every(cls => FONT_SIZE_CLASSES.includes(cls))))) { + while ( + parentNode && !isBlock(parentNode) && + !isUnbreakable(parentNode) && !isUnbreakable(currentNode) && + (parentNode.classList.length === 0 || + [...parentNode.classList].every(cls => FONT_SIZE_CLASSES.includes(cls))) + ) { const isUselessZws = parentNode.tagName === 'SPAN' && parentNode.hasAttribute('data-oe-zws-empty-inline') && parentNode.getAttributeNames().length === 1; diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/format.test.js b/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/format.test.js index 7a3e25086b0..6728f485b87 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/format.test.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/format.test.js @@ -882,6 +882,20 @@ describe('Format', () => { contentAfter: '

[]




', }); }); + it('should apply font size in unbreakable span with class', async () => { + await testEditor(BasicEditor, { + contentBefore: `

some [text]

`, + stepFunction: setFontSize('18px'), + contentAfter: `

some [text]

`, + }); + }); + it('should apply font size in unbreakable span without class', async () => { + await testEditor(BasicEditor, { + contentBefore: `

some [text]

`, + stepFunction: setFontSize('18px'), + contentAfter: `

some [text]

`, + }); + }); }); it('should add style to a span parent of an inline', async () => {