[Tooltip] Change detection runs after showing tooltip
- Dominant language
- TypeScript
- Stars
- 25k
- Forks
- 6.8k
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 91
Description
#### 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?
Contributor guide
Research direction
Start with the linked StackBlitz reproduction and inspect the matTooltip behavior when its value is bound with [matTooltip] on an OnPush element. Compare it with the static matTooltip="..." case and observe the change-detection logs while hovering. Done means hovering does not trigger unnecessary change detection when the @Input() values have not changed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, typescript
- Domain
- frontend, performance
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100