question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug(matTooltip): tooltip doesn't work with ChangeDetectionStrategy.OnPush

See original GitHub issue

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

I have a table with tooltips inside rows:

 <ng-container matColumnDef="icons">
    <th mat-header-cell *matHeaderCellDef>#</th>
    <td mat-cell *matCellDef="let element">
      <span [matTooltip]="'Hello, world'" matTooltipPosition="below"
        >tooltip</span>
    </td>
  </ng-container>

The table can have thousands of rows, that’s why I have to use ChangeDetectionStrategy.OnPush. However, with such strategy tooltips are shown without text.

Reproduction

StackBlitz demo is here

Expected Behavior

Tooltips must be shown with text.

Actual Behavior

Tooltips are shown without text

Environment

  • Angular: 13.3.9
  • CDK/Material: 13.3.7
  • Browser(s): FF 95
  • Operating System (e.g. Windows, macOS, Ubuntu): Ubuntu

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
PavelTurkishcommented, May 24, 2022

@crisbeto Thank you very much for your explanation. This is a modified version of the demo with three modifications:

  • detach() is commented
  • added fooTest getter in .ts {console.log('change was checked'); return true;}
  • added {{fooTest}} in .html

With these modifications when you move mouse over tooltip you see in console change was checked. So, when we don’t call datach() method in constructor angular continues to check view/model. And when I have thousands of rows and any event is processed (keypress, mouse wheel etc) I see serious performance problems although nor view nor model has been changed.

1reaction
PavelTurkishcommented, May 24, 2022

@crisbeto I detach it because I use onPush strategy. If I don’t call this._changeDetectorRef.detach(); then angular doesn’t work in onPush mode (as I understand and as I tested - I am NOT experienced angular user).

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - Angular material tooltip problem with ...
The table can have thousands of rows, that's why I have to use ChangeDetectionStrategy.OnPush . However, with such detection strategy I have a ......
Read more >
How to use matTooltip in Angular Material ? - GeeksforGeeks
First, install the angular material using the above-mentioned command. After completing the installation, Import 'MatTooltipModule' from '@ ...
Read more >
Expression changed after checked error on template : r/Angular2
I'm trying to hide/show a matTooltip programatically and I succeed ... Make sure to set the change Detection strategy to OnPush set on...
Read more >
Angular 9 — Change Detection with Pipe and OnPush Strategy
A Comprehensive Guide to Angular onPush Change Detection Strategy ... To demonstrate this issue, change the previous example to filter the ...
Read more >
May 14 2019 05:43 UTC - angular/angular - Gitter
no bhai i want to open on a click of a button. irfanmayo0786 ... Does anyone meet the error message like this: ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found