From 7587f50140d3e1f964a47d2f4169be069e85ea23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Geelen=20=28sge=29?= Date: Wed, 10 Aug 2022 12:10:55 +0000 Subject: [PATCH] [FIX] web_editor: more robust getRangePosition Ensure getRangePosition do not crash if the current selection is collapsed. task-2154624 Part-of: odoo/odoo#71878 --- .../static/src/js/editor/odoo-editor/src/utils/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 06a2910eeb9..5a3fa2e88f9 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 @@ -2109,7 +2109,7 @@ export function rgbToHex(rgb = '') { export function getRangePosition(el, document, options = {}) { const selection = document.getSelection(); - if (!selection.isCollapsed || !selection.rangeCount) return; + if (!selection.rangeCount) return; const range = selection.getRangeAt(0); const marginRight = options.marginRight || 20;