angular / angular/components

cdk-virtual-scroll-viewport does not handle css position: sticky cleanly

未关闭
#14,833 60 条评论 92 个 reaction 已指派 0 人 在 GitHub 查看
area: cdk/scrolling P3
主要语言
TypeScript
星标
25k
派生
6.8k
平均合并
1 天 8 小时
30 天内合并 PR
91

描述

#### What is the expected behavior?
using the css attribute `position: sticky` should allow for elements to remain displayed according to their sticky parameters.

#### What is the current behavior?
This works for a while but then breaks after a point. Im assuming its a matter of the 'stickied' dom elements getting recycled.

#### What are the steps to reproduce?
https://stackblitz.com/edit/angular-wnar6b-wzjdmh

This is a slightly modified version of an example from the docs. As you scroll the cdk-virtual-scroll-viewport you will notice the light blue headers stick to the the top of their area as expected. Once you exceed a certain amount of scrolling however the headers disappear. For me items 0-2 work but the 3rd one breaks.

Down below is an example using the [non-virtual] scrolling. Here the css attribute works as expected.

#### Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Forked from https://stackblitz.com/angular/apvvljrovad from the docs. no versions changed.

#### Is there anything else we should know?
https://github.com/angular/material2/issues/11621 also gets at my base requirement; wanting some elements of the virtual scroll list to 'stick around'. It would be ideal if standard css properties worked as via this ticket but that might be hard as the whole point of virtual-scroll is to remove things from the dom that 'shouldn't' be rendered. The position: sticky css attribute would seem to break those assumptions.

贡献指南

打开贡献指南

调研方向

使用 cdk-virtual-scroll-viewport 在链接的 StackBlitz 中复现该行为,然后将其与 Angular 文档中的非虚拟滚动示例进行比较。验证滚动超过最初的 sticky 标头后它们会消失。完成的标准是,使用 position: sticky 的元素在整个虚拟滚动过程中都按照其 sticky 参数保持显示。

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

评估

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

把新 issue 发到你的邮箱

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