From e5a6b9cb25f16430d9aecc5e6cc7f45b84ba36eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ella=20van=C2=A0Durpe?= Date: Fri, 19 Mar 2021 19:06:47 +0200 Subject: [PATCH] Only set position if static --- packages/dom/src/dom.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/dom/src/dom.js b/packages/dom/src/dom.js index 04b90d9be4e82f..7e7d9d76001228 100644 --- a/packages/dom/src/dom.js +++ b/packages/dom/src/dom.js @@ -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 );