angular / angular/components

bug(CDK/SCROLLING): <object> element in *cdkVirtualFor is glitching when using "templateCacheSize: 0"

Open
#28,021 0 comments 1 reaction 0 assignees View on GitHub
area: cdk/scrolling P4
Dominant language
TypeScript
Stars
25k
Forks
6.8k
Avg merge
1d 8h
Merged PRs (30d)
91

Description

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

When using No cache strategy (templateCacheSize: 0) for *cdkVirtualFor with element (as image), elements of list glitch while scrolling. Seems like cdkVirtualFor incorrectly init/reinit or reuse instances of listed elements.

When using tag instead of no bug detected.

### Reproduction

StackBlitz link: https://stackblitz.com/edit/uyv2wg?file=src%2Fexample%2Fcdk-virtual-scroll-template-cache-example.html
Steps to reproduce:
1. Create list of 100 elements, use with image link data.
2. Scroll

### Expected Behavior

Smooth scrolling, correct reusing/reinit of list elements, no content replacing.

### Actual Behavior

Scrolling is not smooth (end sometimes end / start of list is unreachable), elements in list are replaced by content of sibling.

### Environment

- Angular: 17.0.0-rc.0 (and 15)
- CDK/Material: 16.2.10
- Browser(s): Chrome
- Operating System (e.g. Windows, macOS, Ubuntu): macOs

Contributor guide

Open the contributing guide

Research direction

Start with the linked StackBlitz reproduction and verify the behavior in Chrome using cdkVirtualFor with templateCacheSize: 0 and object image elements. Read the CDK virtual scrolling implementation around template reuse and compare it with the img case. Done means smooth scrolling with all list items reachable and no content replaced by a sibling.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.