angular / angular/components

bug(virtual-scroll): scrollToIndex does not work for multiple viewports scrolling over the same element

未关闭
#28,469 5 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
area: cdk/scrolling P3
主要语言
TypeScript
星标
25k
派生
6.8k
平均合并
1 天 8 小时
30 天内合并 PR
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

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

贡献指南

打开贡献指南

调研方向

从链接的 StackBlitz 复现开始,重点查看 src/app/example-component.html 和 src/app/example-component.ts,并执行滚动到 viewport 3 和 index 7 的步骤。跟踪多个 viewport 共享同一个元素时的 virtual-scroll 行为,并将最终位置与预期目标进行比较。当按钮滚动到下方 viewport 中的正确项时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
angular, typescript
领域
frontend
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。