Skip to content

Commit

Permalink
fix(getposition): properly determine parents with will-change: transform
Browse files Browse the repository at this point in the history
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
  • Loading branch information
KhaledSakr committed Aug 27, 2020
1 parent ed2ef61 commit 3a76250
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/utils/getPosition.js
Expand Up @@ -240,9 +240,12 @@ const calculateOffset = offset => {
const getParent = currentTarget => {
let currentParent = currentTarget;
while (currentParent) {
const computedStyle = window.getComputedStyle(currentParent);
// transform and will-change: transform change the containing block
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_Block
if (
window.getComputedStyle(currentParent).getPropertyValue('transform') !==
'none'
computedStyle.getPropertyValue('transform') !== 'none' ||
computedStyle.getPropertyValue('will-change') === 'transform'
)
break;
currentParent = currentParent.parentElement;
Expand Down

0 comments on commit 3a76250

Please sign in to comment.