You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] The content and activeAnchor arguments in the render cb do not always refer to the same element #1138
Bug description
I render the contents of the tooltip using the render prop of the Tooltip component
when quickly moving the cursor between two elements, situations arise when activeAnchor argument refers to one element and content argument contains data-tooltip-content from another element.
Is this something that's very noticeable from a user perspective? My guess is that's happening only for a few frames, so barely visible. If that's not the case, and it's in fact noticeable, please provide a reproducible sample, since I've been unable to do reproduce it myself.
In case my assessment is correct, this is something we can't realistically fix right now, since it's due to a design limitation on how the tooltip handles its internal state, and it doesn't impact user experience. As you've noticed from the logs, there are basically 2 render cycles here: first the active anchor changes, and then the other internal states (such as the content) are updated according to it on the next cycle.
I'll leave this open for now, but it should be noted it is closely related to #1010, since the issue there (position and open state synchronization) is also due to how the internal state is handled.
We plan to address this design problem in the near future with v6, so hopefully this will also be fixed alongside #1010.
Thanks for reporting, and please let us know if you've actually come up with a situation where this issue is noticeable for the user.
yes, you're right. the error may be related to this topic.
This bug occurs for 1-2 frames and is only noticeable if the height of tooltips for elements is different. in my example it is the left and middle element. I made a simple repository that you can use to reproduce this bug. I hope it will be useful to you. node js version 18.17.1.
a screenshot of how the user sees it
An interesting detail. when I customized the example, I first used react version 17.0.2. it doesn't show this bug visually. I created a separate branch to reproduce it.
Yep, definitely noticeable when the height changes. This is something we'll keep in mind when working on the design changes for V6.
Though there's something interesting I suggest you try. Does it still happen with the browser dev tools closed? On my computer, with the dev tools closed, I haven't been able to reproduce the bug visually, but if happens every time with it open.
My guess is that the dev tools introduce some performance overhead, so it ends up "lagging" the tooltip a bit. It's worth testing if maybe your application won't be affected by this on a production build.
Still, this is definitely something we're aiming to fix.
If you log the props, you can see that activeAnchor get setState'd one render before content does, so it really does change before. If you use data-tooltip-content, you can keep them in sync by just not reading content and reading the dataset value from the anchor itself, when using render:
Activity
gabrieljablonski commentedon Dec 15, 2023
Is this something that's very noticeable from a user perspective? My guess is that's happening only for a few frames, so barely visible. If that's not the case, and it's in fact noticeable, please provide a reproducible sample, since I've been unable to do reproduce it myself.
In case my assessment is correct, this is something we can't realistically fix right now, since it's due to a design limitation on how the tooltip handles its internal state, and it doesn't impact user experience. As you've noticed from the logs, there are basically 2 render cycles here: first the active anchor changes, and then the other internal states (such as the content) are updated according to it on the next cycle.
I'll leave this open for now, but it should be noted it is closely related to #1010, since the issue there (position and open state synchronization) is also due to how the internal state is handled.
We plan to address this design problem in the near future with v6, so hopefully this will also be fixed alongside #1010.
Thanks for reporting, and please let us know if you've actually come up with a situation where this issue is noticeable for the user.
RedForest347 commentedon Dec 16, 2023
yes, you're right. the error may be related to this topic.
This bug occurs for 1-2 frames and is only noticeable if the height of tooltips for elements is different. in my example it is the left and middle element. I made a simple repository that you can use to reproduce this bug. I hope it will be useful to you. node js version 18.17.1.
a screenshot of how the user sees it

An interesting detail. when I customized the example, I first used react version 17.0.2. it doesn't show this bug visually. I created a separate branch to reproduce it.
thank you for your reply
gabrieljablonski commentedon Dec 16, 2023
Yep, definitely noticeable when the height changes. This is something we'll keep in mind when working on the design changes for V6.
Though there's something interesting I suggest you try. Does it still happen with the browser dev tools closed? On my computer, with the dev tools closed, I haven't been able to reproduce the bug visually, but if happens every time with it open.
My guess is that the dev tools introduce some performance overhead, so it ends up "lagging" the tooltip a bit. It's worth testing if maybe your application won't be affected by this on a production build.
Still, this is definitely something we're aiming to fix.
RedForest347 commentedon Dec 18, 2023
It's true, the bug is not observed visually with the closed dev tools. On a production build with open dev tools the error is also observed.
Very strange behavior...
johannkor commentedon Dec 28, 2023
If you log the props, you can see that
activeAnchorget setState'd one render beforecontentdoes, so it really does change before. If you usedata-tooltip-content, you can keep them in sync by just not readingcontentand reading the dataset value from the anchor itself, when usingrender:RedForest347 commentedon Dec 29, 2023
unfortunately, when using the developer tools, the tooltip height bug is noticeable even when using your variant
gabrieljablonski commentedon Feb 10, 2024
Fixed on official release
react-tooltip@5.26.1