valor-software / ngx-bootstrap

Fast and reliable Bootstrap widgets in Angular (supports Ivy engine)
https://valor-software.com/ngx-bootstrap
MIT License
5.53k stars 1.69k forks source link

tooltip from a templateRef does not hide when the template content is cleared. #3596

Closed panmanphil closed 6 years ago

panmanphil commented 6 years ago

Bug description or feature request:

when you use a straight text value for a tooltip, the code will hide() when that value is not truthy:

 ngOnInit(): void {
    this._tooltip.listen({
      triggers: this.triggers,
      show: () => this.show()
    });
    this.tooltipChange.subscribe((value: any) => {
      if (!value) {
        this._tooltip.hide();
      }
    });
  }

This never happens when the value is a template ref defined like

<input .... [tooltip]="myTemplate' ..../>
<ng-template #myTemplate>
{{aTooltipMessage}}
</ng-template>

the "value" parameter will not be null so you end up with a tiny arrow pointing at the field with nothing in it. This is a simplified example of what I was trying to do but I think illustrates the point. There needs to be some other logic when the tooltip is based on a template reference.

Versions of ngx-bootstrap, Angular, and Bootstrap:

Angular 4.4.6 ngx-bootstrap:2.0.2 Bootstrap:3.3.7

Build system: Angular CLI, System.js, webpack, starter seed:

Angular ng, webpack

valorkin commented 6 years ago

As you can see tooltip can not guess context of template, but you can disable tooltip by using isDisabled option, when aTooltipMessage is empty

jgraffin commented 1 year ago

I had the same issue. Thank you, it worked!