-
-
Notifications
You must be signed in to change notification settings - Fork 533
Tooltips appear in wrong position when placed on top #219
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 issue seems to be related to how close the The tooltip isn't badly positioned when transitioning from the
So this seems to be some kind of issue with the tooltip positioning logic, which is triggered when one tooltip is close to the edge of the viewport, and you transition to another tooltip which has the same or smaller size as the first tooltip you mouse over. Any chance you can take a look at this? |
Am experiencing the same thing. Noticed that after tooltip is hidden, the "left" and "top" style properties are still set to their last values. If unset them prior to hovering over the next element (where would normally get wrong position), e.g. in Chrome Inspector Tools, this seems to not happen. Just created a quick workaround which seems to work based on how tooltip position is updated internally by the component ( https://github.com/wwayne/react-tooltip/blob/master/src/index.js#L380 ): <ReactTooltip effect="solid" ref="tooltipComponent" afterHide={()=>{
var node = ReactDOM.findDOMNode(this.refs.tooltipComponent);
node.style.left = null;
node.style.top = null;
}} /> |
Could someone verify if this issue still exist please? |
as ReactDOM.findDOMNode is deprectaed in strictmode and its usage is discouraged, I found another solution to solve it
|
to give more context on how this error happened in my case, it is as follows, all icons in the previous picture have one line of text for the tooltip, except the last one which has two lines of text hence the tooltip height is bigger than the rest. now if you do the following, hover over the last icon which has a bigger height, then move away from any icons and don't show any tooltip, then go back to hover above an icon which has one line text (smaller height) then the tooltip location is incorrect. |
node --version
v16.8.0
"react-tooltip": "^4.2.21" Still experiencing this issue in 4.2.21. I modified the above workaround to the following, using 'useRef'. import reactDom from 'react-dom';
import { useRef } from 'react';
import ReactTooltip from 'react-tooltip';
export function Component() {
const tooltipComponent = useRef();
return (
<>
<ReactTooltip
effect='solid'
ref={tooltipComponent}
afterHide={() => {
var node = reactDom.findDOMNode(tooltipComponent.current);
node.style.left = null;
node.style.top = null;
}}
/>
<div data-tip='Example'></div>
</>
);
} |
I have no idea what's causing this one, other than it must be a bug in the way the library calculates the position of the element the tooltip is supposed to be attached to. Seems like when moving in one direction the behavior is fine, and when going the other way it breaks.
I had the same issue (tooltip would appear higher than it's supposed to, wrong
top
value) in another page, where the buttons were stacked vertically. Moving from button to button downwards would work fine, but moving upwards would produce the bad position. It also seems sensitive to the size of the tooltip itself, because that one was fixed when I made the tooltip text smaller.Any ideas?
The text was updated successfully, but these errors were encountered: