Skip to content

Commit 3a76250

Browse files
committed
fix(getposition): properly determine parents with will-change: transform
Parent elements with property will-change: transform change the containing block, we have to account for that when calculating the tooltip position. Reference: https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_Block
1 parent ed2ef61 commit 3a76250

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/utils/getPosition.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,12 @@ const calculateOffset = offset => {
240240
const getParent = currentTarget => {
241241
let currentParent = currentTarget;
242242
while (currentParent) {
243+
const computedStyle = window.getComputedStyle(currentParent);
244+
// transform and will-change: transform change the containing block
245+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_Block
243246
if (
244-
window.getComputedStyle(currentParent).getPropertyValue('transform') !==
245-
'none'
247+
computedStyle.getPropertyValue('transform') !== 'none' ||
248+
computedStyle.getPropertyValue('will-change') === 'transform'
246249
)
247250
break;
248251
currentParent = currentParent.parentElement;

0 commit comments

Comments
 (0)