From 3ec95bba969617c091f4aef99a506e0951ea677d Mon Sep 17 00:00:00 2001 From: dhba-odoo Date: Thu, 3 Nov 2022 10:24:42 +0000 Subject: [PATCH] [FIX] web_editor: powerbox overflow not visible Before this commit: In Email Marketing's Mail Body, The Powerbox is opened below the cursor, even when there's not enough space between the cursor line and the window's bottom. As a result, a part of the Powerbox cannot be seen. After this commit: Now, the Powerbox opens itself above the cursor line if it's too close to the window's bottom. Task-3037435 closes odoo/odoo#108352 X-original-commit: ba888c39716f0226adce993cb08852e21b0376eb Signed-off-by: David Monjoie (dmo) --- .../js/editor/odoo-editor/src/powerbox/Powerbox.js | 11 +++++------ .../src/js/editor/odoo-editor/src/utils/utils.js | 5 +++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/src/powerbox/Powerbox.js b/addons/web_editor/static/src/js/editor/odoo-editor/src/powerbox/Powerbox.js index 4f1173806a5..1ab71bd229a 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/src/powerbox/Powerbox.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/src/powerbox/Powerbox.js @@ -272,14 +272,13 @@ export class Powerbox { * @private */ _resetPosition() { - const position = getRangePosition(this.el, this.document); + let options = {}; + if (this.getContextFromParentRect) { + options['parentContextRect'] = this.getContextFromParentRect(); + } + const position = getRangePosition(this.el, this.document, options); if (position) { let { left, top } = position; - if (this.getContextFromParentRect) { - const parentContextRect = this.getContextFromParentRect(); - left += parentContextRect.left; - top += parentContextRect.top; - } this.el.style.left = `${left}px`; this.el.style.top = `${top}px`; } else { 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 0676197c960..0a60eb83e85 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 @@ -2525,6 +2525,11 @@ export function getRangePosition(el, document, options = {}) { offset.left = marginLeft; } + if (options.parentContextRect) { + offset.left += options.parentContextRect.left; + offset.top += options.parentContextRect.top; + } + if ( offset.top - marginTop + offset.height + el.offsetHeight > window.innerHeight && offset.top - el.offsetHeight - marginBottom > 0