angular / angular/components

bug(cdk-experimetal/scrolling): Every item of input array is rendered initially

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

説明

### Is this a regression?

- [ ] Yes, this behavior used to work in the previous version

### The previous version in which this bug was not present was

_No response_

### Description

Initially, before any scrolling occurs; every item of `items` passed to `cdkVirtualFor` is rendered. After scrolling down for a bit (till `translateY` of `.cdk-virtual-scroll-content-wrapper` changes) and scrolling up (even just a bit) the list of rendered elements sharing to only visible elements.

### Reproduction

Could not create stackblitz with `cdk-experimental` nor `angular` v13. Here is an example of what it does in my fairly rudimentary case: https://youtu.be/ILHPaMk2hZU

related code:
```html


```
-----

Steps to reproduce:
1. Create a container and any item template. Fixed height for simplicity is perfect
```

{{item | json}}

```
2. Populate `items` array with 1000 elements
3. View in elements panel, that there is the same number of `div`s as there is of `items`.

### Expected Behavior

I expected only needed elements to be rendered.

### Actual Behavior

Every element of my array is rendered making `cdk-virtual-scroll-viewport` do nothing!

### Environment

Angular CLI: 13.0.3
Node: 14.15.4
Package Manager: npm 7.20.6
OS: win32 x64

Angular: 13.0.2
... animations, cdk, cdk-experimental, common, compiler
... compiler-cli, core, forms, language-service, material
... platform-browser, platform-browser-dynamic, router
... service-worker

Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1300.3
@angular-devkit/build-angular 13.0.3
@angular-devkit/core 13.0.3
@angular-devkit/schematics 13.0.3
@angular/cli 13.0.3
@angular/google-maps 12.1.3
@schematics/angular 13.0.3
rxjs 7.4.0
typescript 4.4.4

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

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

調査の方向性

まず、固定高さの要素を1,000個使用した、提供されている cdkVirtualFor の例を再現し、スクロール前後にレンダリングされる要素を調べます。cdkVirtualFor と autosize の動作を追跡して、初期レンダリングにすべての要素が含まれる理由を特定します。最初から必要な可視要素だけがレンダリングされれば完了です。

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

評価

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

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

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