angular / angular/components

[Tooltip] Change detection runs after showing tooltip

Abierto
#10,306 33 comentarios 81 reacciones 0 asignados Ver en GitHub
area: material/tooltip P3
Lenguaje dominante
TypeScript
Estrellas
25k
Forks
6.8k
Merge medio
1 d 8 h
PR fusionados (30 d)
91

Descripción

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

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza con la reproducción enlazada de StackBlitz e inspecciona el comportamiento de matTooltip cuando su valor está enlazado con [matTooltip] en un elemento OnPush. Compáralo con el caso estático matTooltip="..." y observa los registros de change detection al pasar el cursor. Se considera terminado cuando pasar el cursor no activa una change detection innecesaria si los valores de @Input() no han cambiado.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
angular, typescript
Área
frontend, performance
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
42/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.