Skip to content
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

Virtual scroll: weird behaviour when data is set to empty #16775

Open
el-meher opened this issue Aug 14, 2019 · 2 comments
Open

Virtual scroll: weird behaviour when data is set to empty #16775

el-meher opened this issue Aug 14, 2019 · 2 comments
Labels
area: cdk/scrolling P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@el-meher
Copy link

What are you trying to do?

I have a virtual scroll coupled to a paginated request.
At some point, the user may need to refresh the list.
the new result of the query may be empty so I am setting the data to empty.

What troubleshooting steps have you tried?

The virtual scroll show only the first page after refresh

Reproduction

We can only help if we can reproduce the problem ourselves.

I tried to make a minimal example
https://stackblitz.com/edit/angular-ehqgvp-b5qa5x?file=app/cdk-virtual-scroll-data-source-example.ts

Steps to reproduce:

  1. scroll over list : expected behaviour
  2. click on refresh button
  3. scroll over list : only the first page is shown

Environment

  • Angular: 8.1.2
  • CDK/Material: 8.1.2
  • Browser(s):
  • Operating System (e.g. Windows, macOS, Ubuntu):
@el-meher el-meher added the troubleshooting This issue is not reporting an issue, but just asking for help label Aug 14, 2019
@andrewseguin
Copy link
Contributor

It seems that when you reset cachedData, you need to re-initialize it to what you had in the beginning

https://stackblitz.com/edit/angular-ehqgvp-tu1zid?file=app/cdk-virtual-scroll-data-source-example.ts

@el-meher
Copy link
Author

I investigated the problem and it seems related to FixedSizeVirtualScrollStrategy.prototype._updateRenderedRange.
When the data is empty, it should set the new range to (0,0) but it doesn't.
The logic behind this scroll strategy is that data could only expand, so the size of the range.

@mmalerba mmalerba added the needs triage This issue needs to be triaged by the team label May 20, 2020
@andrewseguin andrewseguin added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent area: cdk/scrolling and removed troubleshooting This issue is not reporting an issue, but just asking for help needs triage This issue needs to be triaged by the team labels May 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: cdk/scrolling P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

No branches or pull requests

3 participants