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.

[Tooltip] Change detection runs after showing tooltip

See original GitHub issue

Bug, feature request, or proposal:

Bug

What is the expected behavior?

Hovering an element with a matTooltip should not trigger change detection on this element if it is an OnPush element and its @Input()s does not change.

What is the current behavior?

Hovering an element with a matTooltip triggers change detection on this element.

This only happens if matTooltip is defined using [matTooltip]="..." and not when it is defined using matTooltip="..."

What are the steps to reproduce?

See https://stackblitz.com/edit/angular-material2-issue-ocg9sj

  • pass the mouse on the red div
  • you get logs everytime the function needed to draw the component are called
  • you don’t get any log from ngOnChanges
  • I would expect that since the @Input() didn’t change, the component shouldn’t be redraw!

What is the use-case or motivation for changing an existing behavior?

Prevent useless redraws

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

cf stackblitz

Is there anything else we should know?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:74
  • Comments:32 (1 by maintainers)

github_iconTop GitHub Comments

23reactions
Need-To-Learncommented, May 31, 2019

Hi, I’m having this issue too with matTooltip directive. The component’s changeDetection is set to ChangeDetectionStrategy.OnPush. On hover / leave, the component’s change detection is triggered multiple times.

mattooltip_cd

Thx !

17reactions
klinkicommented, Jun 11, 2019

I agree, this is a problem for bigger applications with slow change detection cycle. It brings us a lot of problems 😦

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular changeDetector.detectChanges() breaks matTooltip ...
The matTooltip in following component is redering correctly.
Read more >
Change detection in Angular 101 - Sergey Gultyayev - Medium
This error is usually caused when you change some value that is bound to a template changed after the change detection. The most...
Read more >
How to Create a Tooltip Directive in Angular | by Colin Broberg
Let's start at the top. The directive has a required input, the tooltip text itself, and an optional input to change the delay...
Read more >
Create Views for Tooltips (Viz in Tooltip) - Tableau Help
You can show related vizzes in tooltips to help your audience engage with the data at a different or deeper level, while keeping...
Read more >
Change Log - /tooltips - Kendo UI for Angular - Telerik
Bug Fixes · remove extra tooltip shadow in Material theme (#38) · calling show multiple times shows multiple tooltips · tooltip visible after...
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