Skip to content

Commit f6317dd

Browse files
authored
Merge pull request #20389 from calixteman/bug1995579
[Editor] Make sure the left (resp. right) corner of the popup is visible when in LTR (resp. RTL) (bug 1995579)
2 parents 6388610 + cb36dc2 commit f6317dd

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

web/comment_manager.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,15 +1234,26 @@ class CommentPopup {
12341234
if (!correctPosition) {
12351235
this.#editor.commentPopupPosition = [x, y];
12361236
} else {
1237-
const widthRatio =
1238-
this._popupWidth / this.#editor.parentBoundingClientRect.width;
1237+
const parentRect = this.#editor.parentBoundingClientRect;
1238+
const widthRatio = this._popupWidth / parentRect.width;
12391239
if (
12401240
(this.#isLTR && x + widthRatio > 1) ||
12411241
(!this.#isLTR && x - widthRatio >= 0)
12421242
) {
12431243
const buttonWidth = this.#editor.commentButtonWidth;
12441244
x -= widthRatio - buttonWidth;
12451245
}
1246+
const margin = 0.01;
1247+
if (this.#isLTR) {
1248+
x = Math.max(x, -parentRect.x / parentRect.width + margin);
1249+
} else {
1250+
x = Math.min(
1251+
x,
1252+
(window.innerWidth - parentRect.x) / parentRect.width -
1253+
widthRatio -
1254+
margin
1255+
);
1256+
}
12461257
}
12471258
this.#posX = x;
12481259
this.#posY = y;

0 commit comments

Comments
 (0)