[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
This commit is contained in:
Rodolpho Lima
2023-06-26 22:15:47 +02:00
parent 1cb27f3baa
commit 12f34ebeb1
@@ -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;