-
-
Notifications
You must be signed in to change notification settings - Fork 533
[BUG] Wide tooltips can overflow the window boundaries in version 5 #1139
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
Comments
The most "natural" way to do this in V5 would be to use
As you've pointed out, it already does it for same-axis overflow (left switches to right if no space left, top to bottom, and so on) with the This is kind of a weird situation to "fix", since different use-cases would call for different solutions (for example, your "squish" suggestion is totally valid in some cases), but since we already do the left<->right/top<->bottom flip, I don't see why not do this one as well. See |
Thanks for your reply, this looks very helpful. I'll give this a try and report back (and close the issue) once I figure out what middleware fits my use case. |
We'll close the issue once #1140 gets merged. Just let us know if it works properly, or if you have other suggestions about this. |
Hm okay. I think I still want the "squish" behavior even with the middlewares={[
offset(10),
flip(),
size({
apply: ({ availableWidth, availableHeight, elements }) => {
Object.assign(elements.floating.style, {
maxWidth: `${Math.max(200, availableWidth - 50)}px`,
});
},
}),
shift({ padding: 5 }),
flip({
fallbackAxisSideDirection: "start",
}),
]} (I'm not sure why the |
That's good to know. I'm considering adding a section on our documentation covering more clearly (and with examples like this) how to use different middlewares. Though this isn't a huge issue, since most users are completely fine with just the default behavior, so something to get to eventually. |
Official release |
Bug description
When you have a tooltip with long content, it can overflow the window. Solutions to similar reported issues are apparently unavailable in v5. It's particularly apparent when using a left/right placement with dynamic content and/or dynamic layout.
Version of Package
v5.25.0
To Reproduce
See https://codesandbox.io/p/sandbox/react-tooltip-overflow-9srs73
or just do
with some CSS that puts the
<span>
near the center of the screen.Expected behavior
One of the following:
place
(allowing the tooltip content to line-wrap)place
directive, e.g. if I setplace="left"
and it doesn't fit on the left or right, have it go to top/bottom if one of those would fit it on screenScreenshots

Additional context
#476 and #599 seem related, but all of the suggested solutions seem unavailable in v5:
overridePosition
in v5, and theposition
prop doesn't accept functionsafterShow
no longer provides access to the tooltip element (AFAICT), so it is no longer possible to set its styles during the callbackThe text was updated successfully, but these errors were encountered: