Fix tooltip re-position after content resize & respect scroll bars#936
Conversation
| // give the container limited space on both left and top, forcing to bottom-right | ||
| const container = document.createElement('div'); | ||
| container.getBoundingClientRect = () => makeBB(100, 300, 768, 30); | ||
| container.getBoundingClientRect = () => makeBB(50, 300, 768, 30); |
There was a problem hiding this comment.
This change is in response to buffer now being used to compute fit
cjcenizal
left a comment
There was a problem hiding this comment.
This is really awesome man! Nice job fixing this. I found one bug though. Horizontal centering looks fine if there are scrollbars visible, but if there aren't then it looks off-center (Chrome, OS X):
Also, I somehow managed to break things really badly by changing the size of the container element. Here's a screenshot showing the bottom tooltip, but the others are also fubared:
|
I am able to reproduce those issues that @cjcenizal found. Here are some more details. The first one seems to have to only occur when the page reaches it's max-width. Here you can see without scrollbars it's still fine but the screen is smaller than the max-width. And here you can see that once it's reached the max-width the positioning becomes slightly off. The second one also seems to have to do with the max-width on the page. Here are two screenshots of giant width on the guide, one with the max-width and the other without. |
|
@cchaos @cjcenizal tooltip creation now configured to avoid creating scrollbars while determining tooltip placement, this fixes the slightly-misaligned tooltip when no scrollbar is visible. The second problem where the arrow and tooltip are separated is caused by the relationship between the anchor, tooltip, and page body. If you force the anchor to be rendered outside of the page body's bounds (by, saying, giving |
I can't think of a time when we'd need this. The body should be the visible page. At least that's how we've been using it. I think we're OK not worrying too much about this. |






fast follow for #924
EuiTooltipdid not clear its previous knowledge of the tooltip content's size so a window resize & re-hover of the anchor would cause the new tooltip to be influenced by the previous instance's positioningbufferinto account when calculating the content's fit value@cchaos would you mind testing the visuals again to see if you can find any circumstances where tooltip breaks / is malformed?