angular-tooltips icon indicating copy to clipboard operation
angular-tooltips copied to clipboard

Tooltip template updating and tooltip-append-to-body

Open doctornick42 opened this issue 8 years ago • 4 comments

Hi! First, thanks for this lib!

I have a problem with updating template if tooltip-append-to-body attribute is set to 'true'.

I use tooltip to show an information that comes from $http.get(). When tooltip is opened the response is not available yet. If tooltip-append-to-body is false, then everything's fine - my Angular controller get server's response, update its scope and I can see this info in the tooltip.

But, if tooltip-append-to-body is true, then after I get the response then tooltip is just closing. I tried to debug it a bit and found out that after template is modified in my controller then onTooltipTemplateChange event is fired and then this event calls onTooltipShow(). Inside onTooltipShow:

 if ($attrs.tooltipAppendToBody) {
      ...
      removeAppendedTip(tooltipElement); 

And after that the tooltip is closed.

I think it can be caused by that: after this lines inside onTooltipShow there's this code:

if (event && $attrs.tooltipHidden !== 'true') {
    exradicatedTipElement.addClass('_exradicated-tooltip');
    angular.element(window.document.body).append(exradicatedTipElement);
}

If i get the idea right, this code tries to create a copy of the closed tooltip. But unfortunately event variable here is undefined

I'm not sure that I made everything right and even understand everything right but I really stuck with it.

doctornick42 avatar Apr 22 '16 13:04 doctornick42

Hi, which browser and device you tried?

Could be great if you can make a live example with a fiddle or plnkr, usually is not so easy to replicate such issues

45kb avatar Apr 25 '16 07:04 45kb

Ok, sure, live example is a good thing for situations like that.

Here's plunker with a small pseudo example. https://plnkr.co/edit/w3t5ANptwHSxZZ3hD7rP?p=preview

You can change tooltip-append-to-body's value and see that this behavior depends on this attribute.

Tried it on PC with FireFox(Ubuntu, Win), Chrome(Win), Chromium(Ubuntu), Opera(Win), so I think that browser doesn't really matter because all of them showed me the same result.

doctornick42 avatar Apr 25 '16 08:04 doctornick42

Thanks, i will try to debug it, you would the tooltip to stay visible while the content change, correct?

45kb avatar Apr 25 '16 08:04 45kb

Yep, that's right. Thank you!

doctornick42 avatar Apr 25 '16 08:04 doctornick42