From 12f34ebeb18dc326dab6bb95c73cce307deaee31 Mon Sep 17 00:00:00 2001 From: Rodolpho Lima Date: Tue, 30 May 2023 16:29:21 +0000 Subject: [PATCH] [FIX] web_editor: toolbar arrow position in iframe Before this commit the position of the arrow was incorrect when the editor is inside an iframe. For the calculation of `arrowLeftPos` we need the difference between the selection rectangle border and the toolbar's left position. While `correctedSelectionRect.right` is relative to the current iframe's borders, `left` is relative to the top document's window, as it has been offset with `parentContextRect.left`. We need both values to be relative to the same referential in order to make this calculation make sense. task-3347942 X-original-commit: 8bad3a3fb00d59498455205e8d286a38adaf1335 Part-of: odoo/odoo#126445 --- .../static/src/js/editor/odoo-editor/src/OdooEditor.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 830bb286251..a34f7e8d6d3 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 @@ -3080,8 +3080,8 @@ export class OdooEditor extends EventTarget { // Ensure the toolbar doesn't overflow the editor on the right. left = Math.min(window.innerWidth - OFFSET - toolbarWidth, left); // Offset left to compensate for parent context position (eg. Iframe). - left += parentContextRect.left; - this.toolbar.style.left = scrollX + left + 'px'; + const adjustedLeft = left + parentContextRect.left; + this.toolbar.style.left = scrollX + adjustedLeft + 'px'; // Get top position. let top = correctedSelectionRect.top - toolbarHeight - OFFSET;