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 747df41e908..940a7ad3865 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 @@ -1128,7 +1128,7 @@ export function containsUnremovable(node) { export function getInSelection(document, selector) { const selection = document.getSelection(); - const range = !!selection.rangeCount && selection.getRangeAt(0); + const range = selection && !!selection.rangeCount && selection.getRangeAt(0); return ( range && (closestElement(range.startContainer, selector) || diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index 76f45be35d1..6d61364452c 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -1769,7 +1769,7 @@ const Wysiwyg = Widget.extend({ this.toolbar.$el.find('.only_fa').toggleClass('d-none', !$target.is('.fa')); // Hide the create-link button if the selection spans several blocks. const selection = this.odooEditor.document.getSelection(); - const range = selection.rangeCount && selection.getRangeAt(0); + const range = selection && selection.rangeCount && selection.getRangeAt(0); const $rangeContainer = range && $(range.commonAncestorContainer); const spansBlocks = range && !!$rangeContainer.contents().filter((i, node) => isBlock(node)).length; if (!range || spansBlocks) {