Skip to content

Commit

Permalink
Fix(utils): Should correct calculate coordinates to element in refer …
Browse files Browse the repository at this point in the history
…to target element in any situations.
  • Loading branch information
pszczesniak authored Sep 15, 2023
2 parents fe95a50 + bf263d3 commit 76663b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions packages/ckeditor5-utils/src/dom/rect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ export default class Rect {
}

/**
* Returns a new rect, a part of the original rect, which is actually visible to the user,
* Returns a new rect, a part of the original rect, which is actually visible to the user and is relative to the,`body`,
* e.g. an original rect cropped by parent element rects which have `overflow` set in CSS
* other than `"visible"`.
*
Expand Down Expand Up @@ -371,7 +371,7 @@ export default class Rect {
}

/**
* Calculates absolute `Rect` coordinates.
* Recalculates screen coordinates to coordinates relative to the positioned ancestor offset.
*/
public toAbsoluteRect(): Rect {
const { scrollX, scrollY } = global.window;
Expand Down Expand Up @@ -576,7 +576,7 @@ function getElementOverflow( element: HTMLElement | Range ): string {
* (and scrollable) ancestors.
*/
function shiftRectToCompensatePositionedAncestor( rect: Rect, positionedElementAncestor: HTMLElement ): void {
const ancestorPosition = new Rect( positionedElementAncestor ).toAbsoluteRect();
const ancestorPosition = new Rect( positionedElementAncestor );
const ancestorBorderWidths = getBorderWidths( positionedElementAncestor );

let moveX = 0;
Expand Down
8 changes: 4 additions & 4 deletions packages/ckeditor5-utils/tests/dom/position.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ describe( 'getOptimalPosition()', () => {
parent.appendChild( element );

assertPosition( { element, target, positions: [ attachLeftBottom ] }, {
top: -900,
left: -920,
top: 100,
left: 80,
name: 'left-bottom'
} );
} );
Expand Down Expand Up @@ -307,8 +307,8 @@ describe( 'getOptimalPosition()', () => {
parent.scrollTop = 100;

assertPosition( { element, target, positions: [ attachLeftBottom ] }, {
top: 200,
left: 280,
top: 1200,
left: 1280,
name: 'left-bottom'
} );
} );
Expand Down

0 comments on commit 76663b4

Please sign in to comment.