From 1cb27f3baa45e9fe6d4f33f2bf0c994c74c4b0df Mon Sep 17 00:00:00 2001 From: Rodolpho Lima Date: Tue, 6 Jun 2023 11:49:51 +0000 Subject: [PATCH] [FIX] web_editor: toolbar position in scrolled iframe Before this commit, an error in the toolbar position happened when the editor was inside an iframe and the iframe's window had scroll bars. Steps to reproduce: - go to the Market Automation app (enterprise edition) - create new campaign - add new activity - create a new mail template by typing a name and selecting "create and edit" - select the "plain text" theme - add a lot of content in order to have the scroll bars - scroll down - select something to display the toolbar The `scrollX` and `scrollY` variables in `_positionToolbar` are ment to correct the floating toolbar position in case the document in which the toolbar is mounted has some scrolloffset. As the floating toolbar is always mounted on the body of the top document, this is the document to watch for scroll offsets, and not the inner document when the editor is mounted inside an iframe. task-3263463 X-original-commit: fb080218def7c47e7b96cf284d613fc03b8325f6 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 6d27df91f09..830bb286251 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 @@ -3070,8 +3070,8 @@ export class OdooEditor extends EventTarget { const editorRect = this.editable.getBoundingClientRect(); const parentContextRect = this.options.getContextFromParentRect(); const editorTopPos = Math.max(0, editorRect.top); - const scrollX = this.document.defaultView.scrollX; - const scrollY = this.document.defaultView.scrollY; + const scrollX = document.defaultView.scrollX; + const scrollY = document.defaultView.scrollY; // Get left position. let left = correctedSelectionRect.left + OFFSET;