Skip to content

Avoid populating cached bounds when fixed itemSize is zero - #923

Merged
bvaughn merged 2 commits into
bvaughn:mainfrom
feritcemkahraman:fix/zero-fixed-item-size-bounds
Oct 18, 2026
Merged

bvaughn merged 2 commits into
bvaughn:mainfrom
feritcemkahraman:fix/zero-fixed-item-size-bounds

Conversation

@feritcemkahraman

Copy link
Copy Markdown
Contributor

Summary

  • When cachedBounds.itemSize is a fixed numeric size of 0 (for example, before a percentage-sized container's initial measurement), getStartStopIndices previously fell through to the variable-size path and walked cachedBounds.get(index) across all itemCount items, populating up to $O(n)$ zero-size entries in cachedBounds.
  • Handle itemSize === 0 in $O(1)$ without populating cachedBounds, preserving the exact visible/overscan start and stop indices of the linear lookup across negative, zero, and positive scroll offsets.

Testing

  • npx prettier --check lib/core/getStartStopIndices.ts lib/core/getStartStopIndices.test.ts
  • npx eslint lib/core/getStartStopIndices.ts lib/core/getStartStopIndices.test.ts
  • TARGET=lib npx vite build
  • npx vitest run lib --maxWorkers=1 (22 test files, 208 tests passed)
  • Note: integrations/* workspace packages and Playwright e2e integration suites were not installed/run locally.

@vercel

vercel Bot commented Oct 18, 2026

Copy link
Copy Markdown

@feritcemkahraman is attempting to deploy a commit to the Brian Vaughn's projects Team on Vercel.

A member of the Team first needs to authorize it.

…izes

- createCachedBounds: fixed numeric sizes return computed bounds instead of
  memoizing one Map entry per lookup.
- getStartStopIndices: any fixed size takes the O(1) branch; zero, negative
  or NaN sizes render only the first item (previously offset 0 rendered the
  last rows, and negative offsets mounted every row).
- useItemSize: normalize NaN/negative/non-finite sizes (e.g. "abc%") to 0 so
  estimated size is never NaN.
@bvaughn
bvaughn merged commit 7c82b01 into bvaughn:main Oct 18, 2026
7 of 8 checks passed
@bvaughn

bvaughn commented Oct 18, 2026

Copy link
Copy Markdown
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants