-
-
Notifications
You must be signed in to change notification settings - Fork 532
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
[FEAT REQ] Dynamic callback for disabling tooltip #1210
Comments
I'll take a deeper look when I got some more time, but IIRC, your suggestion is not exactly viable. I believe a For instance, we currently do support I'll try to come up with something to address your problem (the first thing that comes to mind is virtualizing your table), but I'm not sure there's anything we can do easily internally with the tooltip. |
You are correct that data-* attributes must be strings. I considered using a callback to make the solution more generic. However, my current implementation is with In my current application, I am already using virtualization. Despite this, with 50 rows and 10 columns, the grid alone generates 500 tooltips. Additionally, there are other virtualized lists that add even more tooltips at any given time. Please let me know if my use case seems reasonable and if you think it requires and is worth your and my time. In my opinion, any medium to large-scale application can easily reach this number of tooltips, and having to add and remove event listeners along with other operations for all of them raises performance concerns. |
I'm convinced this is a feature that is worth looking into. We might not be able to do it through a Something like this could work nicely. It's literally just your suggestion, but as a prop instead. <Tooltip
// Using the "overflowing text" logic from your use-case.
disableAnchor={anchorRef => anchorRef.scrollWidth <= anchorRef.offsetWidth}
/> Just not sure about calling it |
How would this work if this is not the expected behaviour for all tooltips across the app ? Are you suggesting we add a separate Although as a workaround I can add some HTML data attribute as an identifiers and read them inside the callback for making decisions. |
Yep. Your idea of having something like I wouldn't call it a "workaround", since the intention of this callback is to have the decision logic completely outside the tooltip code. Internally, we'll just call |
Sounds perfect, thank you for entertaining my request and immediate responses. I will be happy to drop a PR on this for you to add corrections if you wish so. |
@gabrieljablonski just curious if we are dealing with the core problem of having so many event listeners in V6 ? Me and my team are exploring the possibility of building and implementing a custom tooltip component for replacing react-tooltip's basic usecases in my app, which would be having a single event listener following event delegation pattern. |
The idea of event delegation might be an interesting approach, but we have to investigate if that allows us to keep the tooltip functionality mostly the same, and if that does in fact improve performance. For instance, let's say we use But I'm just guessing, this needs to be investigated. Anyway, thanks for the suggestion! As a sidenote, we also do have an "imperative mode", which allows to control the tooltip programmatically without the need of event listeners necessarily. But depending on the use case, this method might be unviable. Just something to keep in mind. |
Available on v5.28.0 |
In my application, I work with large datasets displayed in a data grid, where each cell has a tooltip. This extensive use of tooltips results in significant scripting time whenever a user interacts with them. The addEventListener and removeEventListener functions run on every cell and tooltip across the app. Consequently, even simple actions like scrolling or hovering through different cells through the table cause a considerable amount of scripting activity, impacting performance.
Currently, I've implemented a workaround tailored to my use case. Tooltips are necessary only when the data within a cell is clipped and an ellipsis appears. However, this solution is limited and not ideal for broader scenarios as it helps only because it reduces the amount of tooltips instead of solving the core problem.
I propose adding a
data-tooltip-dynamic-hide
attribute that accepts a callback function.This callback would:
data-tooltip-dynamic-hide={(anchorElement)=>anchorElement.scrollWidth <= anchorElement.offsetWidth}
This approach would allow for more flexible and efficient tooltip management, accommodating various use cases and improving overall performance.
Alternatives I have explored for far
Additional context
I will be happy to open a PR introducing this feature or discussing other solutions around this.
Tooltips added on most basic example of tanstack table.
https://codesandbox.io/p/sandbox/angry-night-32nr8q
The text was updated successfully, but these errors were encountered: