primeng icon indicating copy to clipboard operation
primeng copied to clipboard

Issue Title

Open rc14193 opened this issue 3 weeks ago • 1 comments

Describe the bug

The lazy virtual scroll example preallocates the virtual collection to be the same as the simulated collection on the server. Most other examples of lazy virtual scroll allocate a certain page size and then grow the collection as the user scrolls. This behavior can be replicated in primeng, but when a user scrolls back to the top the scroll bar reszies to be the same as if it only had the original page size loaded.

Pull Request Link

No response

Reason for not contributing a PR

  • [ ] Lack of time
  • [ ] Unsure how to implement the fix/feature
  • [ ] Difficulty understanding the codebase
  • [x] Other

Other Reason

I think the solution is to make sure a spacer is set and add a line here that calls this.setSpacerSize. This is the workaround I am using in my lazy load call back by calling that explicitly. There are other behavioral issues with lazy virtual scroll I've encountered though such as if I use expanded columns when the full number of results has been lazy loaded if I have expanded columns and expand multiple this triggers a load event over and over because of the size of the scroll area. While calling the setSpacerSize works I don't think it's a complete solution, and I'm wondering if using the item pixel size needs to be changed for the calculation in this case.

Reproducer

https://stackblitz.com/edit/7ycnwz6y?file=src%2Fmain.ts

Environment

Chrome Version 142.0.7444.176 (Official Build) (64-bit)

Angular version

19

PrimeNG version

v20

Node version

No response

Browser(s)

No response

Steps to reproduce the behavior

  1. Create a virtual scroll with lazy load that only displays a set page size, say 50
  2. Pull from a collection from either a server or sim server that has a large number of items
  3. Scroll to the bottom a few times to see the items loaded and added to the virtual collection and the scroll bar scroll box shrink showing there are more elements
  4. Scroll all the way back to the top and see the scroll bar scroll box resize to be small again

Expected behavior

The scroll bar scroll box should remain small indicating that the lazy loaded items are still a part of the items present on the client. An easy example is going to reddit and scrolling down a few times. The loading icon appears, more posts are loaded, the scroll bar size changes but if you scroll back to the top the scroll box remains the updated smaller size

rc14193 avatar Dec 04 '25 16:12 rc14193

Github isn't allowing adding the gifs for some reason but here as example of the expected behavior as shown by reddit. The gif loops quickly so it looks like the scroll box resizes but that is from the gif starting over.

rc14193 avatar Dec 04 '25 16:12 rc14193