Bug
I have a disabled (disabled = true) tooltip on a button. When I click on the button, I change the disabled state to false and after a few seconds I change it back to true.
Expected: The tooltip should be showed for a few seconds, then disapear.
The tooltip does not show. You have to leave the button with your mouse and hover it again to see the tooltip.
Here is a blitz that reproduces the problem:
https://stackblitz.com/edit/angular-material-copied-to-clipboard-tooltip?file=app%2Ftooltip-position-example.html
For a copy to clipboard button, it is common to inform the user that the data has been copied to the clipboard.
Angular 5.2.0
Angular Material 5.2.0
You can do it with the show and hide api methods:
@ViewChild(MatTooltip) _matTooltip: MatTooltip;
...
onCopyButtonClick() {
this.copiedTooltipDisabled = false;
setTimeout(() => this._matTooltip.show());
setTimeout(() => {
this.copiedTooltipDisabled = true;
this._matTooltip.hide();
}, 4000);
}
Closing as this is working as expected. If you would like to show and hide the tooltip programatically you should use the show/hide methods.
Sorry to ask @julianobrasil but I'm trying to find the way to define a Viewchild for my tooltip with a specific name (I have several tooltips in my page), can you give me a snippet?
The MatTooltip directive has an exportAs attribute (it's exported as "matTooltip"). You can check it without looking for it at the code, just reading the doc site at the API tab:

So, you can do something like this:
<button mat-button
matTooltip="Look at this tip"
#tp="matTooltip">
Just click me
</button>
After that, you can get a reference to it by using the _template reference variable_ "tp".
@ViewChild('tp') _matTooltip: MatTooltip;
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._
Most helpful comment
The
MatTooltipdirective has anexportAsattribute (it's exported as "matTooltip"). You can check it without looking for it at the code, just reading the doc site at the API tab:So, you can do something like this:
After that, you can get a reference to it by using the _template reference variable_ "tp".