-
-
Notifications
You must be signed in to change notification settings - Fork 533
Tooltip with big text content overflows the window #476
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
I have the same issue, and it's especially weird since the tooltip adjusts fine when it overflows on the right side. |
I think someone with a mobile screen figure out how to adjust the styles so
it didn't overflow, but IDK which issue it might be in....
…On Thu, Mar 14, 2019 at 10:22 AM AlexLaRochelle ***@***.***> wrote:
I have the same issue, and it's especially weird since the tooltip adjusts
fine when it overflows on the right side.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#476 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AS_pnVcVs10YIm0nD3Ngmk_HrsL4GOhfks5vWltDgaJpZM4bl5Ku>
.
|
I managed to fix this (I really don't know if it works in all cases) by applying a class with Seems to work fine on mobile and desktop |
It might be browser specific, look at those scary eyes on my screenshot 🙈. Chrome 72.0.3626.121 on Linux here. https://react-tooltip.netlify.com/ $(".demonstration a[data-tip]").dataset.tip = "Hello multiline tooltip Hello multiline tooltip Hello multiline tooltip Hello multiline tooltip Hello multiline tooltip Hello multiline tooltip Hello multiline tooltip Hello multiline tooltip Hello multiline tooltip Hello multiline tooltip Hello multiline tooltip Hello multiline tooltip Hello multiline tooltip Hello multiline tooltip Hello multiline tooltip Hello multiline tooltip Hello multiline tooltip "
$(".demonstration a[data-tip]").style.left = 0;
$(".__react_component_tooltip.place-top.type-dark ").style.maxWidth = "70vw" And try different widths, sometimes it works, sometimes it doesn't. |
+1 Would love to see this fixed :) |
I have a very similar issue. place="right" only works for mobile view and on desktop view it goes back to the default style place="top" despite the prop being set as place="right". |
+1 |
Having this issue as well |
+1 |
@wwayne or @aronhelser are there any workarounds you can provide until this can be fixed? Looking to the future are there any plans in the pipeline for react tooltip to smartly choose the best location where it won't get cutoff? Thanks 😄 |
I am happy to accept any PRs that the community can provide! Wayne has moved on to other projects, and I am not actively working with React anymore. I am acting as a caretaker, more or less. I hope that one of the people experiencing this issue can work on it.... |
I was able to get around it with |
Or having it based dynamically off of the trigger node: overridePosition: ({ left, top }, currentEvent) => {
// This function is called 3 times (once with target node & twice with event)
// so we need to compute the targetNode
const targetNode = currentEvent.getBoundingClientRect ? currentEvent : currentEvent.target;
const { top: targetNodeTop } = targetNode?.getBoundingClientRect?.() || {};
return { left, top: targetNodeTop || top };
} In this case, my tooltip is |
I would like to contribute to this issue. |
@ashishsurana we can work together. 👍 |
I use the className field and add the class mw-20 this fix my problem. |
This seems to fix for me: overridePosition={({ left, top }, _e, _t, node) => {
return {
top,
left: typeof node === 'string' ? left : Math.max(left, 0),
};
}} But I also used |
This is how I fixed it (thanks @mrclay for your example): overridePosition={({left, top}, event, triggerElement, tooltipElement) => {
return {
top,
left: Math.min(left, window.innerWidth - tooltipElement.offsetWidth),
};
}} |
Thank you it help me to |
With Tailwindcss, I fixed this using max-width: <ReactTooltip
id="default-tooltip"
place="top"
className="max-w-[70%] md:max-w-[50%] xl:max-w-[40%] 2xl:max-w-[20%]"
/> "react-tooltip": "^5.26.0" Thanks @emicarito ! |
I changed a few things on the examples page and was able to replicate the issue. When there is a big text on the tooltip and the element isn't centered in the screen, it gets cut off on the left side.
When there is more text it even splits it into multiple lines but still doesn't respect the left side boundary.
Any ideas to make it respect the left side and wrap content with newlines earlier?
The text was updated successfully, but these errors were encountered: