Skip to content

Commit

Permalink
Updated how the getPositionedAncestor() is used in the getOptimalPosi…
Browse files Browse the repository at this point in the history
…tion() because it no longer considers the passed element. Refactoring in tests.
  • Loading branch information
oleq committed Apr 10, 2020
1 parent 28a0bb7 commit 50bb75c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/ckeditor5-utils/src/dom/position.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export function getOptimalPosition( { element, target, positions, limiter, fitIn
limiter = limiter();
}

const positionedElementAncestor = getPositionedAncestor( element.parentElement );
const positionedElementAncestor = getPositionedAncestor( element );
const elementRect = new Rect( element );
const targetRect = new Rect( target );

Expand Down
21 changes: 10 additions & 11 deletions packages/ckeditor5-utils/tests/dom/position.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,20 +237,19 @@ describe( 'getOptimalPosition()', () => {
}, {
position: 'absolute',
borderLeftWidth: '20px',
borderTopWidth: '40px'
borderTopWidth: '40px',
overflow: 'scroll',
width: '10px',
height: '10px',
background: 'red'
} );

Object.assign( element.style, {
width: '20px',
height: '20px',
marginTop: '100px',
marginLeft: '200px'
} );

Object.assign( parent.style, {
overflow: 'scroll',
width: '10px',
height: '10px'
marginLeft: '200px',
background: 'green'
} );

parent.appendChild( element );
Expand All @@ -260,8 +259,8 @@ describe( 'getOptimalPosition()', () => {
parent.scrollTop = 100;

assertPosition( { element, target, positions: [ attachLeftBottom ] }, {
top: 160,
left: 260,
top: 200,
left: 280,
name: 'left-bottom'
} );
} );
Expand Down Expand Up @@ -696,7 +695,7 @@ function getElement( rect = {}, styles = {} ) {
styles.borderTopWidth = '0px';
}

window.getComputedStyle.withArgs( element ).returns( styles );
Object.assign( element.style, styles );

return element;
}
Expand Down

0 comments on commit 50bb75c

Please sign in to comment.