From 32c77e26ffdd061713322a4dbf4253d630ef85a4 Mon Sep 17 00:00:00 2001 From: Jinjiu Liu Date: Thu, 27 Jul 2023 10:28:15 +0200 Subject: [PATCH] [FIX] web_editor: dynamicplaceholder at the end positions below the page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reproduction: 1. Install Sales, Email Marketing 2. Go to Email template by searching 3. Click the Sales: Send Quotation template and make a duplicate 4. Add empty lines in the template, till it almost reaches the end of the page 5. Use slash command to add a Dynamic holder, and it’ll be positioned below the page Fix: compute the position by consider the height/width of the popover to make sure it’ll be always in the page opw-3373403 task-3442559 closes odoo/odoo#153969 X-original-commit: 583ef2441e6aa9a6d13f50991a0d1d3a54c31db1 Signed-off-by: Geelen Sébastien (sge) --- addons/web_editor/static/src/js/backend/html_field.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/addons/web_editor/static/src/js/backend/html_field.js b/addons/web_editor/static/src/js/backend/html_field.js index 64c1a6c4ee5..d13a90d5e8f 100644 --- a/addons/web_editor/static/src/js/backend/html_field.js +++ b/addons/web_editor/static/src/js/backend/html_field.js @@ -370,10 +370,16 @@ export class HtmlField extends Component { * @param {Object} position */ positionDynamicPlaceholder(popover, position) { - let topPosition = this.wysiwygRangePosition.top; + // make sure the popover won't be out(below) of the page + const enoughSpaceBelow = window.innerHeight - popover.clientHeight - this.wysiwygRangePosition.top; + let topPosition = (enoughSpaceBelow > 0) ? this.wysiwygRangePosition.top : this.wysiwygRangePosition.top + enoughSpaceBelow; + // Offset the popover to ensure the arrow is pointing at // the precise range location. let leftPosition = this.wysiwygRangePosition.left - 14; + // make sure the popover won't be out(right) of the page + const enoughSpaceRight = window.innerWidth - popover.clientWidth - leftPosition; + leftPosition = (enoughSpaceRight > 0) ? leftPosition : leftPosition + enoughSpaceRight; // Apply the position back to the element. popover.style.top = topPosition + 'px';