Merge pull request #20299 from calixteman/bug1990104

[Editor] Use some percent coordinates for the comment dialog (bug 1990104)
This commit is contained in:
calixteman 2025-09-24 18:45:16 +02:00 committed by GitHub
commit a8cf9a41d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -624,6 +624,7 @@ class CommentDialog {
this.#prevDragY = clientY; this.#prevDragY = clientY;
pointerMoveAC = new AbortController(); pointerMoveAC = new AbortController();
const { signal } = pointerMoveAC; const { signal } = pointerMoveAC;
const { innerHeight, innerWidth } = window;
dialog.classList.add("dragging"); dialog.classList.add("dragging");
window.addEventListener( window.addEventListener(
"pointermove", "pointermove",
@ -633,8 +634,8 @@ class CommentDialog {
} }
const { clientX: x, clientY: y } = ev; const { clientX: x, clientY: y } = ev;
this.#setPosition( this.#setPosition(
this.#dialogX + x - this.#prevDragX, this.#dialogX + (x - this.#prevDragX) / innerWidth,
this.#dialogY + y - this.#prevDragY this.#dialogY + (y - this.#prevDragY) / innerHeight
); );
this.#prevDragX = x; this.#prevDragX = x;
this.#prevDragY = y; this.#prevDragY = y;
@ -693,16 +694,14 @@ class CommentDialog {
this.#uiManager?.removeEditListeners(); this.#uiManager?.removeEditListeners();
this.#saveButton.disabled = true; this.#saveButton.disabled = true;
const parentDimensions = options?.parentDimensions; const parentDimensions = options?.parentDimensions;
const { innerHeight, innerWidth } = window;
if (editor.hasDefaultPopupPosition()) { if (editor.hasDefaultPopupPosition()) {
const { dialogWidth, dialogHeight } = this._dialogDimensions; const { dialogWidth, dialogHeight } = this._dialogDimensions;
if (parentDimensions) { if (parentDimensions) {
if ( if (
this.#isLTR && this.#isLTR &&
posX + dialogWidth > posX + dialogWidth >
Math.min( Math.min(parentDimensions.x + parentDimensions.width, innerWidth)
parentDimensions.x + parentDimensions.width,
window.innerWidth
)
) { ) {
const buttonWidth = this.#editor.commentButtonWidth; const buttonWidth = this.#editor.commentButtonWidth;
posX -= dialogWidth - buttonWidth * parentDimensions.width; posX -= dialogWidth - buttonWidth * parentDimensions.width;
@ -717,13 +716,15 @@ class CommentDialog {
} }
} }
const height = Math.max(dialogHeight, options?.height || 0); const height = Math.max(dialogHeight, options?.height || 0);
if (posY + height > window.innerHeight) { if (posY + height > innerHeight) {
posY = window.innerHeight - height; posY = innerHeight - height;
} }
if (posY < 0) { if (posY < 0) {
posY = 0; posY = 0;
} }
} }
posX /= innerWidth;
posY /= innerHeight;
this.#setPosition(posX, posY); this.#setPosition(posX, posY);
await this.#overlayManager.open(this.#dialog); await this.#overlayManager.open(this.#dialog);
@ -752,8 +753,8 @@ class CommentDialog {
this.#dialogX = x; this.#dialogX = x;
this.#dialogY = y; this.#dialogY = y;
const { style } = this.#dialog; const { style } = this.#dialog;
style.left = `${x}px`; style.left = `${100 * x}%`;
style.top = `${y}px`; style.top = `${100 * y}%`;
} }
#finish() { #finish() {