From cb36dc28a71bfa08bc9db40e20bee80d11ee1194 Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Wed, 22 Oct 2025 22:47:20 +0200 Subject: [PATCH] [Editor] Make sure the left (resp. right) corner of the popup is visible when in LTR (resp. RTL) (bug 1995579) --- web/comment_manager.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/web/comment_manager.js b/web/comment_manager.js index 572df94c5..eaff727bd 100644 --- a/web/comment_manager.js +++ b/web/comment_manager.js @@ -1234,8 +1234,8 @@ class CommentPopup { if (!correctPosition) { this.#editor.commentPopupPosition = [x, y]; } else { - const widthRatio = - this._popupWidth / this.#editor.parentBoundingClientRect.width; + const parentRect = this.#editor.parentBoundingClientRect; + const widthRatio = this._popupWidth / parentRect.width; if ( (this.#isLTR && x + widthRatio > 1) || (!this.#isLTR && x - widthRatio >= 0) @@ -1243,6 +1243,17 @@ class CommentPopup { const buttonWidth = this.#editor.commentButtonWidth; x -= widthRatio - buttonWidth; } + const margin = 0.01; + if (this.#isLTR) { + x = Math.max(x, -parentRect.x / parentRect.width + margin); + } else { + x = Math.min( + x, + (window.innerWidth - parentRect.x) / parentRect.width - + widthRatio - + margin + ); + } } this.#posX = x; this.#posY = y;