Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firefox bug in getOffsetParent computation with "fixed" position element as firstElementChild #837

Closed
adilyalcin opened this issue Nov 5, 2019 · 0 comments
Labels
bug Something is not working. Fixed in popper@2.x This issue has been fixed in version 2.x

Comments

@adilyalcin
Copy link

adilyalcin commented Nov 5, 2019

Hey all,

There's a very specific bug I encountered with Firefox where the offset element is computed inside popper.js.

Based on MDN spec page for DOM offsetParent property:

offsetParent returns null ... if the element has position property set to fixed. (firefox returns <body>)

I have a fixed element somewhere along the shared DOM as first child, which gets picked for input to the getOffsetParent method. Chrome initializes the offsetParent to null, and continues finding the correct offsetParent eventually. Firefox initializes the offsetParent variable to < body > instead. It messes up the position calculations where I attach popper to a different reference element.

The related function is getOffsetParent.

  var offsetParent = element.offsetParent || null;
  // Temporary fix
  if( isFirefox && getStyleComputedProperty(element,'position')=="fixed"){
    offsetParent = null;
  }

I do not currently have the time to create the CodePen sample to replicate the issue, but I may be able to do it a little later. The bug appears in a really specific DOM configuration! And, I'm using tippy library, so it will take extra effort to isolate the bug to using only popper and/or approved libraries here.

I hope the code & documentation case is clear.

Let me know if you have any questions or concerns!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working. Fixed in popper@2.x This issue has been fixed in version 2.x
Projects
None yet
Development

No branches or pull requests

2 participants