You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 364c071
Browse filesBrowse the repository at this point in the historyBrowse files
fix: clamp initialItemCount to data length when data prop is used (#1461)
* fix: clamp initialItemCount to data length when data prop is used
When initialItemCount exceeds data.length, buildListStateFromItemCount
creates phantom items with data: undefined. These phantom items produce
zero-height DOM elements, triggering Zero-sized element console errors.
Clamp the adjusted count to data.length when the data prop is provided
(non-empty array), so Virtuoso never renders more initial items than exist
in the data array. When data is not used (totalCount-only mode), the
existing behavior is preserved.
Relates to #1060 -- the prior fix (PR #1061) addressed a ResizeObserver
timing issue in useSize, but this separate code path in
buildListStateFromItemCount was never patched.
* chore: add changeset for initialItemCount clamp fix
* fix: prevent phantom items in all initialItemCount code paths
Follow-up to the data.length clamp, covering the remaining gaps:
- clamp the count to the data remaining after initialTopMostItemIndex,
which could still read past the end of the array
- treat an explicitly empty data array as zero items, while omitted
data keeps the index-driven initial rendering
- add initialItemCount to the list state combineLatest so publishing it
recomputes immediately; previously it was read from a stale cell and
a data shrink in the same render cycle produced undefined items,
crashing computeItemKey in unmeasured (hidden) viewports
- add a 13-input combineLatest overload to urx
---------
Co-authored-by: Petyo Ivanov <[email protected]>
Fixed "Zero-sized element, this should not happen" error when `initialItemCount` exceeds the available `data`. The initial list state builder now clamps the item count to the data remaining after `initialTopMostItemIndex`, and renders no items when `data` is explicitly empty, preventing phantom items with `undefined` data from being rendered. `initialItemCount` also became a reactive input of the list state computation, so changing it after mount recomputes the list instead of leaving stale state until an unrelated update.
0 commit comments