skip to Main Content

This is my code. I am getting 2 tooltips in Safari. I want one tooltip that I have already prepared.

Can you kindly let me know how to make the default browser tooltip disappear?

<div  
  [attr.id]="'nodeRow-'+node.id" 
  [ngClass]="selectedID===node.id?'node-title-active':'node-title-inactive'" 
  class="row node-title" 
  (mouseenter)="overlayEffecton(node)" 
  (mouseleave)="overlayEffectoff(node)" 
  matTooltip="{{node.name}}" 
  matTooltipPosition="right" 
  matTooltipHideDelay="3" 
  matTooltipClass="right">

2

Answers


  1. It looks like your framework is generating a title attribute on the rendered page. You need to set the title attribute to be empty.

    Example Code (untested):

    import { Directive, ElementRef, Renderer2 } from '@angular/core';
        
        @Directive({
          selector: '[disableTitleTooltip]'
        })
        export class DisableTitleTooltipDirective {
          constructor(private el: ElementRef, private renderer: Renderer2) {
            this.renderer.setAttribute(this.el.nativeElement, 'title', '');
          }
        }
    

    And add the selector to your element:

    <div  
      [attr.id]="'nodeRow-'+node.id" 
      [ngClass]="selectedID===node.id?'node-title-active':'node-title-inactive'" 
      class="row node-title" 
      (mouseenter)="overlayEffecton(node)" 
      (mouseleave)="overlayEffectoff(node)" 
      matTooltip="{{node.name}}" 
      matTooltipPosition="right" 
      matTooltipHideDelay="3" 
      matTooltipClass="right"
      disableTitleTooltip>
    
    Login or Signup to reply.
  2. Use [attr.title]="null">.

    <div  
      [attr.id]="'nodeRow-'+node.id" 
      [ngClass]="selectedID===node.id ? 'node-title-active' : 'node-title-inactive'" 
      class="row node-title" 
      (mouseenter)="overlayEffecton(node)" 
      (mouseleave)="overlayEffectoff(node)" 
      matTooltip="{{node.name}}" 
      matTooltipPosition="right" 
      matTooltipHideDelay="3" 
      matTooltipClass="right" 
      [attr.title]="null">
    </div>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search