angular / angular/components

[Tooltip] Change detection runs after showing tooltip

オープン
#10,306 コメント 33 件 リアクション 81 件 担当者 0 名 GitHub で見る
area: material/tooltip P3
主要言語
TypeScript
スター
25k
フォーク
6.8k
平均マージ
1日 8時間
マージ済み PR(30日)
91

説明

#### 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?

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

リンクされた StackBlitz の再現から始め、OnPush 要素で値が [matTooltip] によってバインドされているときの matTooltip の動作を調べます。静的な matTooltip="..." のケースと比較し、ホバー中の change detection のログを確認します。@Input() の値が変更されていない場合に、ホバーによって不要な change detection が発生しなければ完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
angular, typescript
領域
frontend, performance
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
42/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。