question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:78
  • Comments:42 (9 by maintainers)

github_iconTop GitHub Comments

31reactions
florenthobeincommented, Mar 18, 2019

My use case is that I need a sticky header always present above a virtually-scrolling list ; I’m probably not the only one. Would you guys accept a PR that allows such a behavior (namely, a sticky header)?

30reactions
wartabcommented, Jul 16, 2019
Read more comments on GitHub >

github_iconTop Results From Across the Web

position:fixed doesn't work inside cdk-virtual-scroll-viewport
The transform property makes and child that is position fixed treat that parent as the containing block rather than the body of the...
Read more >
CSS position:sticky Not Working? Try This Fix
Before you begin troubleshooting, confirm that position: sticky is compatible with your target browser. Check here. Sticky Element's Placement ...
Read more >
Using CSS Position Sticky in Webflow - YouTube
I'll be showing you how I figured out how to to use position sticky for the new Fast.co homepage in ... Your browser...
Read more >
Making an element sticky within a container
How to use CSS and jQuery to fix the position of an element ... While we do have position: sticky available to us,...
Read more >
How to Fix Issues With CSS Position Sticky Not Working?
There could be a number of reasons why the CSS position: sticky property might not be working for you. You can check the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found