[FIX] web_editor: more robust getRangePosition

Ensure getRangePosition do not crash if
the current selection is collapsed.

task-2154624

Part-of: odoo/odoo#71878
This commit is contained in:
Sébastien Geelen (sge)
2022-08-26 17:16:10 +02:00
parent 09be8678bb
commit 7587f50140
@@ -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;