-
-
Notifications
You must be signed in to change notification settings - Fork 79k
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
Tooltip, if element is removed tooltip is left there #2298
Comments
The plugin could be modified to have the tooltip be a child element of whatever it's attached to, but then traversing said element might be off (ie: if you're expecting a set number of children). Having the tooltip hide when the element is removed would be spotty, as browser support for DOM Mutation events isn't top notch, and IE is unique of course. The simplest solution would be for you to just call |
A solution could be to implement the "destroy" event (with: http://v3.javascriptmvc.com/jquery/dist/jquery.event.destroyed.js for example). Then, attach the destroy event to the tooltiped object and destroy the tooltip when element is destroy. |
You can display tooltips inside the element using the "inside" option in placement. However, that has a few problems of it's own. I recommend just destroying it along with the element when you remove it. |
good enough, thanks |
Here's how I'm doing it (CoffeeScript):
'hide' seems to destroy, which makes sense in this context. |
@timscott I just profiled the |
_@dhruv-bhatia_ Okay, so although the tooltip element is removed from the DOM, which is what I verified, the event on the target element remains in memory? Yes it would be nice to have |
@timscott Yes, that's what I observed - I managed to fix it by calling FYI, you may want to inspect your own app's memory usage - http://gent.ilcore.com/2011/08/finding-memory-leaks.html |
Please empty the tooltip element before rendering again. Hope it helps! |
Not a real solution but i made my own tooltip using like this. >component.html
...
>component.scss .myTooltip .myTooltipText { .myTooltip .myTooltipText::after { .myTooltip:hover .myTooltipText { |
None of the accepted answers seemed to resolve my issue, and would just leave the tooltip floating mid-page, and then upon scrolling, it would move to the top left of the page due to the absolute positioning. (I'm using Vue, and the element already had an @click event on it, so I added a parent wrapping div and applied an inline event there)
|
In my case the tooltip was attached to a button which would be removed immideatly after being clicked (but the tooltip would still remain visible). So, I check for obsolete tooltips after every click, and if they are found, remove them. ("body").on("click", e => {
hideObsoleteTooltips()
})
function hideObsoleteTooltips() {
// Find all existing tooltips
const tooltips = $(".tooltip")
for (const t of tooltips) {
// Find the initiator of this tooltip
const initiator = $(`[aria-describedby="${t.id}"]`)
// If the initiator is no longer visible, remove the tooltip
if (initiator.is(":hidden")) {
t.remove()
}
}
} |
If control on which tooltip is shown is removed then tooltip is left there and it's stuck there forever.
Steps:
Display a tooltip on a link
When hover over link tooltip is shown
Now clicking on that link removes link from the DOM
Tooltip is left there and never going away
The text was updated successfully, but these errors were encountered: