-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[Tooltip] custom flip behavior causing placement issues due to margin #12084
Comments
For what it's worth, this issue is slightly exacerbated by the use of an inline arrow-function in MUI's
For every update on |
@Sharakai I can't find of any better workaround that applying the same margin to the tooltip, no matter the placement. Unfortunately, we can't move this logic into the core as it's breaking the On a related topic, we might have the same issue with the auto placement. But it's not something we officially support. At least yet. |
@oliviertassinari I presume, then, that any consumer defining a custom Happy to close if this is considered un-fixable at present. Thanks for looking at it nevertheless 👍 |
@Sharakai Yes, I think that it's structural. I can't see how we could make both works at the same time. We have to prioritize, start/end feature wins. Be aware that we have reworked the Tooltip implementation. Your following code sample will no longer work as expected: <Tooltip
title="My Tooltip"
placement="right"
classes={{ tooltip: props.classes.tooltip }}
PopperProps={{
modifiers: {
flip: {
behavior: ["right", "top", "left", "bottom"]
}
}
}}
> I'm working on fixing this breaking change. Hold on. |
Expected Behavior
When the Tooltip is provided with a custom
flip
behavior
(viaPopperProps
, it should be positioned correctly, in the order specified, and with correct separation from the target to the tooltip.Current Behavior
If the custom
flip
behavior
causes the tooltip to go from right/left to top/bottom, then the tooltip pops in and out at different places as it is opening/closing, and it does not position correctly causing it to overlap the target.This is because there are multiple updates occurring within
react-popper
(at least one as a result of the currentmaterial-ui
implementation), and the currentTooltip
styles apply only a left-right margin (if placement is "left" or "right") or a top-bottom margin (if placement is "top" or "bottom").placement
prop).popper.js
determines that the tooltip doesn't fit to the right, but DOES fit at the top.popper.js
determines that the tooltip doesn't fit at the right or top (because of the additional margin), but does to the left.Steps to Reproduce (for bugs)
You can see this in the following codesandbox, by hovering over the red "Tile" and watching the tooltip "pop" in at the top before settling at the top-left,
https://codesandbox.io/s/l464lv7wv9?module=%2Fsrc%2Fpages%2Findex.js
(See
src/pages/index.js
for the implementation)If you uncomment the
margin: 14px !important
on line 17, you'll see that the issue is fixed as the tooltip will now have a constant size regardless of placement. This will now mean, however, that the tooltip cannot push up against the edge of the viewport, and will be (at a minimum) 14px from the edge (but perhaps this can be countered by a negative position, e.g.top -14px
?).Context
We have a tile that can be dragged around the screen, with a large tooltip that provides helpful information on hover. When the user drags the tile to the top right, we get this issue.
Your Environment
The text was updated successfully, but these errors were encountered: