diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js b/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js index 4ee545cf2e6..33a9ac919bb 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js @@ -1686,7 +1686,7 @@ export class OdooEditor extends EventTarget { */ _computeHistorySelection() { const sel = this.document.getSelection(); - if (!sel.anchorNode) { + if (!(sel && sel.anchorNode)) { return this._latestComputedSelection; } this._latestComputedSelection = { diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/sanitize.js b/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/sanitize.js index 1904f8c3ff3..71550aecb97 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/sanitize.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/sanitize.js @@ -123,7 +123,8 @@ class Sanitize { node = nodeP; } - const anchor = this.root.ownerDocument.getSelection().anchorNode; + const selection = this.root.ownerDocument.getSelection(); + const anchor = selection && selection.anchorNode; const anchorEl = anchor && closestElement(anchor); // Remove zero-width spaces added by `fillEmpty` when there is // content and the selection is not next to it.