angular / angular/components

[Tabs] Toggling quickly can cause content to be duplicated

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

説明

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

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

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

調査の方向性

まず app/app.component.ts の StackBlitz reproduction を実行し、lazy-loaded tabs、NgForTrackBy、OnPush、setTimeout を使ったキーボードによる高速な選択を行います。タブコンテンツのレンダリングパスを追跡して、コンテンツが複数回表示される理由を特定します。繰り返し高速に切り替えても reproduction が常にちょうど 1 つのインスタンスを保持すれば完了です。

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

評価

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

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

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