Popper-core: Doesn't work inside tables

Created on 18 May 2017  路  20Comments  路  Source: popperjs/popper-core

CodePen demo

https://codepen.io/anon/pen/RVeQyL

Steps to reproduce the problem

  1. Put reference element inside of a table
  2. Initialize Popper.js on it

What is the expected behavior?

Popper should show up next to reference element.

What went wrong?

Popper shows up in wrong location, or if page is scrolled, sometimes it gets hidden.

# BUG 馃悶 medium Fixed in v2 medium core

Most helpful comment

I can verify also that this doesn't work in <th> elements. I worked around it by changing my <th> elements to <td> elements, but that does hurt my brain a bit.

All 20 comments

EDIT: I've reproduced with popper only and switched the jsbin to codepen.

Umh that's unexpected 馃

@FezVrasta any clue on why this happens?

Nope, sorry but I'm not at home these days so I'm not able to investigate.

Updated the codepen to make it more clear

I'm seeing the issue as popper.offsetParent returning a grandparent with position: relative, instead of the <td> container element, and am able to work around it by setting position: relative on the <td> directly.

@mponizil that only works partially, because the popper width will be calculated based on the width of the td, and so will be constrained if you have a lot of text and want the popper width to adjust automatically.

@aristidesfl hah, indeed I realized that just after posting!

Best workaround I've found so far:

new Tooltip({
      container: document.body,  
      boundariesElement: document.body
})

The problem is this:
image

https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent

I guess I'll have to create a custom offsetParent implementation to get rid of this quirkiness..

You all guys, please review #363 and let me know if it fixes your problems.

released as 1.11.0

Not sure if it is a big thing to fix, but the fix in #276 doesn't work for <th> elements.

I can verify also that this doesn't work in <th> elements. I worked around it by changing my <th> elements to <td> elements, but that does hurt my brain a bit.

Agreed, this doesn't work inside <th>. Reopen!

I have an issue with tables too. Small tooltips are correctly-positioned, but once they are a bit tall, they get mispositioned. The target is inside a TD.

Small tooltip (correct)

screen shot 2018-06-01 at 17 02 20

Big tooltip (incorrect)

screen shot 2018-06-01 at 17 02 52
screen shot 2018-06-01 at 17 02 36

Outside of the table (correct)

screen shot 2018-06-01 at 17 04 23

Workaround that works for now:

<div class="table-responsive" style="margin:-200px 0;">
    <table class="table" style="padding:-200px 0;">
        <!-- popovers and tooltips inside will now work -->
    </table>
</div>

Works if container is outside of .table-responsive

We still have an issue with popover inside table wrapped in a Bootstrap table-responsive container.

I think it may be related to this issue.

Update: my issue seems more related to issue #611.

These issues should be fixed in v2, I don't have any codepen to test it (since the recent examples rely on Bootstrap), but similar table-related issues are fixed so I'm pretty confident.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tyrw picture tyrw  路  4Comments

skitterm picture skitterm  路  5Comments

Madhu94 picture Madhu94  路  3Comments

FezVrasta picture FezVrasta  路  3Comments

cixonline picture cixonline  路  5Comments