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