diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index 3aa283f28ed..ecd3099967b 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -1974,7 +1974,9 @@ export class Wysiwyg extends Component { if (color && !isCSSColor(color) && !weUtils.isColorGradient(color)) { color = (colorType === "text" ? 'text-' : 'bg-') + color; } - const coloredElements = this.odooEditor.execCommand('applyColor', color, colorType === 'text' ? 'color' : 'backgroundColor', this.lastMediaClicked); + let coloredElements = this.odooEditor.execCommand('applyColor', color, colorType === 'text' ? 'color' : 'backgroundColor', this.lastMediaClicked); + // Some nodes returned by applyColor can be removed of the document by the sanitization in historyStep + coloredElements = coloredElements.filter(element => this.odooEditor.document.contains(element)); const coloredTds = coloredElements && coloredElements.length && Array.isArray(coloredElements) && coloredElements.filter(coloredElement => coloredElement.classList.contains('o_selected_td')); if (coloredTds.length) {