components icon indicating copy to clipboard operation
components copied to clipboard

bug(md-tooltip): tooltip is not removed when parent is

Open ivoviz opened this issue 10 years ago • 5 comments

Consider a scenario where there's a button inside a container. The button has a tooltip and on click it should set a variable to another value. Based on that value the container element is added / removed with ngIf. Simple example:

<div *ngIf="!hidden">
  <button
    md-button
    md-tooltip="Hide this button"
    tooltip-position="after"
    (click)="hidden = true">HIDE ME!</button>
</div>

After clicking the button the container div is removed, however, the tooltip remains still, no way to remove it.

Plunkr example.

ivoviz avatar Aug 24 '16 15:08 ivoviz

hello any workarounds ?

lghinet avatar Sep 20 '16 11:09 lghinet

It's a bit hacky, but what I'm doing now is adding

MdTooltip.prototype.ngOnDestroy = function () {
    this._overlayRef.dispose();
    this._overlayRef = null;
};

to node_modules/@angular2-material/tooltip/tooltip.js (just put it after the ngOnInit prototype).

ivoviz avatar Sep 20 '16 11:09 ivoviz

@ivoviz 's hack still works in alpha.9, after the changes of the module structure. However, now need to edit the ~/node_modules/@angular/material/material.umd.js.

gucheen avatar Sep 28 '16 05:09 gucheen

@jelbourn , Just wanted to know any plan to fix this issue soon?

tapas4java avatar Oct 06 '16 15:10 tapas4java

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.