Skip to content

fix(cdk/scrolling): virtual scroll flickers in zoneless mode. #29777

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jacob-noble
Copy link

@jacob-noble jacob-noble commented Sep 23, 2024

When provideExperimentalZonelessChangeDetection is enabled, virtual-scroll-viewport flickers during scroll because the transform operation becomes visible. This fix moves the style transform into the afterNextRender phase to ensure it stays invisible.

Fixes #29174

When provideExperimentalZonelessChangeDetection is enabled,
virtual-scroll-viewport flickers during scroll because
the transform operation becomes visible.
This fix moves the style transform into the
afterNextRender phase to ensure it stays invisible.

Fixes angular#29174
@jacob-noble jacob-noble requested a review from a team as a code owner September 23, 2024 17:06
@jacob-noble jacob-noble requested review from crisbeto and amysorto and removed request for a team September 23, 2024 17:06
@andy-clapson
Copy link

This is a sharp-looking pull request!

@atscott atscott requested review from mmalerba and removed request for crisbeto September 24, 2024 04:49
@atscott
Copy link
Contributor

atscott commented Sep 24, 2024

This is exactly how it was in d91d0d4 before it was reverted due to an internal breakage and moved outside in 32d2683.

This will require another round of unpacking the problem and re-evaluating potential solutions. IIRC, this one broke scrolling entirely in the app. Once scrolling started, it never stopped.

@jacob-noble
Copy link
Author

@atscott - Thanks for taking the time to look at this. I wasn't aware that this was a solution that was tried previously.

I haven't run into the issue where scrolling broke entirely yet (either in the local environment or in one of the projects I'm involved in that makes use of this fix as a patch). Do you know how to reproduce that issue?

@mmalerba mmalerba removed their request for review February 20, 2025 02:25
@rdlabo
Copy link

rdlabo commented May 18, 2025

I've tried @jacob-noble 's this solution and it works fine. Either with fixed-size-virtual-scroll or with my own dynamic-size-virtual-scroll (@rdlabo/ngx-cdk-scroll-strategies ) also.

Maybe the 32d2683 breakage is version-dependent. I have it working fine in the following environment.

@angular/core: 19.2.9
@angular/cdk“: 19.2.14

@bobbyg603
Copy link
Contributor

I ran into the virtual scroll flicker today in a zoneless ionic app. The changes in this PR appear to fix the problem, and I haven't noticed any detrimental side-effects to scrolling anywhere else in the app.

For anyone looking to try this fix I forked this repo and applied @jacob-noble 's fix to the 19.2.x branch and published the package to npm as @workingdevshero/cdk.

@bobbyg603
Copy link
Contributor

I ran into the virtual scroll flicker today in a zoneless ionic app. The changes in this PR appear to fix the problem, and I haven't noticed any detrimental side-effects to scrolling anywhere else in the app.

For anyone looking to try this fix I forked this repo and applied @jacob-noble 's fix to the 19.2.x branch and published the package to npm as @workingdevshero/cdk.

fwiw virtual scroll is still broken in 20 despite zoneless being stable. this fix also works in 20.0.x

@atscott
Copy link
Contributor

atscott commented Jun 2, 2025

Zoneless is not stable in v20. It is in developer preview. I have also verified that this change still breaks the internal application's scrolling.

@jacob-noble
Copy link
Author

Zoneless is not stable in v20. It is in developer preview. I have also verified that this change still breaks the internal application's scrolling.

@atscott - Can you provide context around how to verify that this change breaks scrolling (how to reproduce it)?

@atscott
Copy link
Contributor

atscott commented Jun 2, 2025

I don't have that information, no.

@jacob-noble
Copy link
Author

I have also verified that this change still breaks the internal application's scrolling.

Sorry, so when you say:

I have also verified that this change still breaks the internal application's scrolling.

How did you do this?

@rdlabo
Copy link

rdlabo commented Jun 2, 2025

@atscott I'm curious about that too. I tested this across four different apps but couldn’t reproduce any scrolling interruptions. Could it be a browser issue? Or maybe something related to device specs? Even the smallest clue would be super helpful—I'd really appreciate any additional info you can share.

@atscott
Copy link
Contributor

atscott commented Jun 2, 2025

I ask the team to patch in the change, run the application, and check if the scrolling is broken. The issue is that when scrolling is performed, it continues infinitely.

The change in this PR affects the timing of the transform being applied. It applies it after change detection has run in the application rather than how it is now, where it's performed first. It's possible that there is some other computation in a component that depends on the transform existing before the component refreshes.

I have proposed a different change in #31240 which preserves the existing timing of the transform being set.

@rdlabo
Copy link

rdlabo commented Jun 8, 2025

@atscott Thanks for the detailed explanation! Thanks to you, I was able to hold off on the official release.

I'm looking forward to seeing the pull request at #31240 get merged. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug(cdk/scrolling): virtual-scroll flickers during scroll in zoneless mode
5 participants