From ded7bb08959edee5f1e2dce490cdc53de9af31fd Mon Sep 17 00:00:00 2001 From: Antoine Guenet Date: Thu, 2 Feb 2023 14:08:08 +0000 Subject: [PATCH] [FIX] web_editor: limit custom table selection to editable area bounds The custom table selection was not limited to the editable area bounds, which means we could end up styling a table as selected, which did not belong to the editor's scope. This sometimes happened when Firefox triggered a selectionchange event during the instantiation of the editor and the selection happened to be in a table outside the editor. opw-3150654 task-3166078 closes odoo/odoo#111779 X-original-commit: d51aab54775ed541d7955cee032aceed143d3a08 Signed-off-by: David Monjoie (dmo) --- .../static/src/js/editor/odoo-editor/src/OdooEditor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 960927b6030..0b31d685568 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 @@ -2204,7 +2204,7 @@ export class OdooEditor extends EventTarget { _handleSelectionInTable(ev=undefined) { const selection = this.document.getSelection(); const anchorNode = selection.anchorNode; - if (anchorNode && closestElement(anchorNode, '[data-oe-protected="true"]')) { + if (anchorNode && (closestElement(anchorNode, '[data-oe-protected="true"]') || !ancestors(anchorNode).includes(this.editable))) { return false; } this.deselectTable();