Skip to content

Virtualizer: Items overlap when dynamic content expands heights #9519

@mykhailo-ivankiv

Description

@mykhailo-ivankiv

Provide a general summary of the issue here

In react-aria-components  Virtualizer with  ListLayout and estimatedRowHeight for variable heights, expanding item content (e.g., accordion, image load) causes overlap with subsequent items. Items do not shift properly despite measurement.

Video:
https://github.com/user-attachments/assets/6c078ed4-5a75-4b74-a192-72351f463244

Minimal reproducible example:
https://stackblitz.com/edit/vitejs-vite-j4eu8ny2?file=src%2Findex.css,vite.config.ts,src%2Fmain.tsx,src%2FExample.tsx&terminal=dev

🤔 Expected Behavior?

Virtualizer detects height change (via ResizeObserver or layout), remeasures, and repositions items without overlap, similar to react-window. (https://react-window.vercel.app/list/dynamic-row-height)

😯 Current Behavior

Expanding item content (e.g., accordion, image load) causes overlap with subsequent items

💁 Possible Solution

Option 1: Per-Item ResizeObserver
• Attach  ResizeObserver to each rendered  ListBoxItem  (visible items only).
• On resize, invalidate layout measurements and trigger Virtualizer re-compute
• Pros: Precise, automatic for content changes (images, text expand).
• Cons: Observer overhead (but low, ~10-20 visible items); ensure cleanup on unmount.

Option 2: Static “View Frame” Rendering
• Replace absolute positioning with a single scrollable “viewport” container holding statically positioned items (no transforms).
• Use  IntersectionObserver on viewport sections/frames to pre-render batches.
• Pros: Natural CSS flow, no overlap; easier dynamic heights.
• Cons: Less efficient for ultra-large lists (renders more); complex frame management

🔦 Context

No response

🖥️ Steps to Reproduce

Please follow the video and the minimal reproducible example

Version

1.14.0

What browsers are you seeing the problem on?

Firefox, Chrome

If other, please specify.

Probably in any browse

What operating system are you using?

Mac OS 26.2

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

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