angular / angular/components

[Tabs] Toggling quickly can cause content to be duplicated

Ouverte
#10,938 14 commentaires 8 réactions 0 personnes assignées Voir sur GitHub
area: material/tabs P3
Langage dominant
TypeScript
Étoiles
25k
Forks
6.8k
Merge moyen
1 j 8 h
PR mergées (30 j)
91

Description

#### Bug, feature request, or proposal:

I have had some trouble reproducing this one reliably (it seems to occur more often on my app than in reproductions) but there seems to be a race condition related to the rendering of tab content when it is lazy-loaded.

#### What is the expected behavior?

Tab content should only be displayed once.

#### What is the current behavior?

Toggling tabs very quickly (using arrow keys + space bar) can cause tab content to be drawn multiple times.

#### What are the steps to reproduce?

StackBlitz: https://stackblitz.com/edit/angular-material2-issue-h6pgut?file=app%2Fapp.component.ts

I am intentionally trying to be awkward in terms of timing (ie. setting the `selectedTabIndex` in a timeout), but this behaviour still should not happen.

I have recorded a reproduction in this video: https://gfycat.com/ReadyFairBasil
Note that at the start there is only one instance of each tab's content but by the end the second tab's content is duplicated.

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

Bug

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

Latest StackBlitz (Angular 6-rc2, Material 6-rc1)

#### Is there anything else we should know?

I could only reproduce by using lazy-loaded tabs + NgForTrackBy + OnPush + window.setTimeout, but these may not be necessary. I also had to use keyboard selection to toggle fast enough to trigger the issue.

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par exécuter la reproduction StackBlitz dans app/app.component.ts et testez une sélection rapide au clavier avec des onglets chargés paresseusement, NgForTrackBy, OnPush et setTimeout. Suivez le chemin de rendu du contenu des onglets afin d’identifier pourquoi le contenu apparaît plus d’une fois ; c’est terminé lorsque la reproduction conserve exactement une instance lors de basculements rapides répétés.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
angular, typescript
Domaine
frontend
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
38/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.