Skip to content

Commit

Permalink
Only set position if static
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Mar 19, 2021
1 parent 0e4fcfd commit e5a6b9c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/dom/src/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,14 @@ function hiddenCaretRangeFromPoint( doc, x, y, container ) {
const originalZIndex = container.style.zIndex;
const originalPosition = container.style.position;

const { position = 'static' } = getComputedStyle( container );

// A z-index only works if the element position is not static.
if ( position === 'static' ) {
container.style.position = 'relative';
}

container.style.zIndex = '10000';
container.style.position = 'relative';

const range = caretRangeFromPoint( doc, x, y );

Expand Down

0 comments on commit e5a6b9c

Please sign in to comment.