Skip to content

Virtual-scroll doesn’t fully render on data swap; missing CDK-style reflow API #1884

@Arsalanliaqat

Description

@Arsalanliaqat

Description

I’m seeing this behavior in our Ionic 7 / Angular 20 app when using @rx-angular/template’s *rxVirtualFor with variable‐height items:

  1. I push a brand-new array into the virtual scroll (e.g. when the day changes).
  2. I immediately call viewport.scrollToIndex(0, 'auto').
  3. Only the first 2–3 items render. The rest remain blank until I manually scroll, at which point the viewport measures and paints them.

That suggests the viewport is still using stale height calculations after the data swap.

Steps to Reproduce

  1. Bind an Observable<T[]> into:
 <rx-virtual-scroll-viewport
   [dynamic]="getItemSize"
   [runwayItems]="runway"
   #viewport>
   <div *rxVirtualFor="let item of items$; trackBy: '_id'">
     <!-- item template -->
   </div>
 </rx-virtual-scroll-viewport>
  1. In component code swap the list:
 this.items$.next([...newItems]);
 viewport.scrollToIndex(0, 'auto');
  1. Observe only a couple of rows render.
  2. Scroll manually → the rest appear.

Environment

  • Angular: 20.0.5
  • Ionic: 7.x
  • @rx-angular/cdk: 20.0.0
  • @rx-angular/template: 20.0.0
  • Browser: Chrome 115.0.5790.170
  • OS: macOS Monterey 12.6

Questions / Requests

  1. Is there an equivalent to CDK’s checkViewportSize() on RxVirtualScrollViewportComponent to force an immediate reflow of dynamic or autosize strategies?
  2. If not, what is the recommended pattern to make sure the full list is measured and rendered immediately when swapping the data array? (I’m currently working around it by waiting for the (rendered) callback or using requestAnimationFrame.)
  3. Would you consider exposing a public “refresh” API (e.g. refresh() or reflow()) so that scrollToIndex(0) always works as expected after an array swap?

Thanks in advance for any pointers or code snippets!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions