bug(virtual-scroll): scrollToIndex does not work for multiple viewports scrolling over the same element
- 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
If you have multiple viewports beneath eachother the function 'scrollToIndex' does not work if you want to scroll to an element in one of the bottom lists. It scrolls to a wrong position.
### Reproduction
StackBlitz link: https://stackblitz.com/edit/components-issue-dch1m4?file=src%2Fapp%2Fexample-component.html,src%2Fapp%2Fexample-component.ts,src%2Fapp%2Fexample-component.css
Steps to reproduce:
1. Click the button 'Scroll to viewport 3 and index 7'
2. It scrolls to the wrong position.
### Expected Behavior
It should scroll to the correct position.
### Actual Behavior
It should scroll to the wrong position.
### Environment
- Angular: 16.2.1
- CDK/Material: 16.2.1
- Browser(s): Chrome
- Operating System (e.g. Windows, macOS, Ubuntu): Stackblitz
Contributor guide
Research direction
Start with the linked StackBlitz reproduction, especially src/app/example-component.html and src/app/example-component.ts, and run the steps for scrolling to viewport 3 and index 7. Trace the virtual-scroll behavior for multiple viewports sharing one element and compare the resulting position with the expected target. Done means the button scrolls to the correct item in the bottom viewport.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100