From 09736d81c844b1caa1cea16ead8134de8d9823bd Mon Sep 17 00:00:00 2001 From: Jinjiu Liu Date: Tue, 3 Oct 2023 11:13:15 +0200 Subject: [PATCH] [FIX] web_editor: patch for null selection in condition Reproduction: 1. Go to any record with a chatter 2. Open full composer 3. Enter a special case for the text using shortcuts (CTRL+I for italic, CTRL+B for bold, etc) 4. exit the special case with the same shortcut 5. JS error Reason: A selection is not null check is missing in the condition Related PR: https://github.com/odoo/odoo/pull/136777 closes odoo/odoo#137499 X-original-commit: db0325503576d06521ab65a64d3c9cce837e66bc Signed-off-by: David Monjoie (dmo) Signed-off-by: Jinjiu Liu (jili) --- .../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 098b3a5a817..ec179255412 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 @@ -741,7 +741,7 @@ export function getSelectedNodes(editable) { */ export function getDeepRange(editable, { range, sel, splitText, select, correctTripleClick } = {}) { sel = sel || editable.parentElement && editable.ownerDocument.getSelection(); - if (sel.isCollapsed && sel.anchorNode && sel.anchorNode.nodeName === "BR") { + if (sel && sel.isCollapsed && sel.anchorNode && sel.anchorNode.nodeName === "BR") { setCursorStart(sel.anchorNode.parentElement, false); } range = range ? range.cloneRange() : sel && sel.rangeCount && sel.getRangeAt(0).cloneRange();