diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index 51fbaf1c5946106ea21ae63bd4541dd2e3084616..b12b2db35ffd817cb7319434f104ad7e3af5b29b 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -1620,17 +1620,19 @@ const Wysiwyg = Widget.extend({ } const fonts = this.odooEditor.execCommand('applyColor', color, eventName === 'foreColor' ? 'color' : 'backgroundColor', this.lastMediaClicked); - // Ensure the selection in the fonts tags, otherwise an undetermined - // race condition could generate a wrong selection later. - const first = fonts[0]; - const last = fonts[fonts.length - 1]; - - const sel = this.odooEditor.document.getSelection(); - sel.removeAllRanges(); - const range = new Range(); - range.setStart(first, 0); - range.setEnd(...endPos(last)); - sel.addRange(range); + if (!this.lastMediaClicked) { + // Ensure the selection in the fonts tags, otherwise an undetermined + // race condition could generate a wrong selection later. + const first = fonts[0]; + const last = fonts[fonts.length - 1]; + + const sel = this.odooEditor.document.getSelection(); + sel.removeAllRanges(); + const range = new Range(); + range.setStart(first, 0); + range.setEnd(...endPos(last)); + sel.addRange(range); + } const hexColor = this._colorToHex(color); this.odooEditor.updateColorpickerLabels({