Search code examples
angularangular-materialtooltiptouch

matTooltipTouchGestures='off' also disables tooltips for non-touch gadgets


I want to disable some of my matTooltips (like those inside scrollable/draggable lists, ...). According to API reference for Angular Material tooltip there is a suitable input property called

@Input('matTooltipTouchGestures')
touchGestures: TooltipTouchGestures

with type TooltipTouchGestures = 'auto' | 'on' | 'off'

But when I add the [matTooltipTouchGestures]="'off'" property to my tooltip item, then the tooltip becomes disabled for my non-touch gadgets as well, i.e.: no tooltip is shown when i hover the button with my mouse on desktop.

This is an example of how I applied the property:

<button (click)="myFunction()"
   mat-raised-button
   matTooltip="bla bla bla"
   [matTooltipTouchGestures]="'off'">
   <mat-icon>
       dashboard
   </mat-icon>
</button>

Am I doing something wrong here?


Solution

  • I had to to add some dependent stuff:

    // app.module.ts
    
    import {MAT_TOOLTIP_SCROLL_STRATEGY_FACTORY_PROVIDER, MatTooltipModule} from "@angular/material/tooltip";
    import {BrowserModule, HAMMER_GESTURE_CONFIG, HammerGestureConfig, HammerModule} from '@angular/platform-browser';
    
    @NgModule({
        ...
        providers: [
            MAT_TOOLTIP_SCROLL_STRATEGY_FACTORY_PROVIDER,
            {provide: HAMMER_GESTURE_CONFIG, useClass: HammerGestureConfig},
            ...
        ]
    })