svelte-material-ui icon indicating copy to clipboard operation
svelte-material-ui copied to clipboard

Tooltips create each a separate dom node in body

Open KraXen72 opened this issue 4 years ago • 5 comments

Describe the bug Tooltips each create a separate dom node in body.

To Reproduce add a few tooltips see inspect element

Expected behavior tooltips should probably change only one element and reposition it or only as much as needed from a global tooltip pool. smui shouldn't fill up the document body with tooltips. either create them programatically with conditional rendering in svelte (if else or svelte:component) or atleast put them in some kind of wrapper so they dont' directly pollute document body

KraXen72 avatar Nov 23 '21 19:11 KraXen72

That's how they work. They are hoisted to the body element so they appear on top of all other elements.

hperrin avatar Nov 23 '21 19:11 hperrin

If I were to use one element for all tooltips, Svelte would be very confused during destruction. It's already bad enough that I'm moving the element. Svelte often stumbles over that on hot module reloading.

hperrin avatar Nov 23 '21 19:11 hperrin

can't they just conditionally render to the body on hover? like only render when the bound element is hovered

KraXen72 avatar Nov 24 '21 08:11 KraXen72

@hperrin bumping this with a related question. How are non-rich tooltips meant to clean up their hoisted body element, when the tooltip's containing component is destroyed? I'm seeing the destroy method get called, which looks like it leads to event listeners getting removed, but the hoisted mdc-tooltip element still hangs around. It seems like this could potentially lead to a memory leak. How are these meant to get destroyed?

I'm using the v7.0.0-beta-12 btw, but I've been seeing the same thing since at least beta-0.

drewrygh avatar Jun 29 '23 03:06 drewrygh