{{ message }}
Repository navigation
fix(virtual-core): read shouldAdjustScrollPositionOnItemSizeChange from options - #1232
Closed
xianjianlf2 wants to merge 1 commit into
Closed
xianjianlf2 wants to merge 1 commit into
xianjianlf2 wants to merge 1 commit into
Conversation
…om options The predicate was documented as the escape hatch to restore pre-3.14 scroll compensation behavior, but resizeItem read it from an instance field that setOptions never assigned, so supplying it through options silently did nothing and there was no working way to opt out of the backward-scroll compensation skip. Read it from options first (and expose it on VirtualizerOptions), falling back to a directly-assigned instance field for back-compat. Closes TanStack#1227
Collaborator
This was referenced Jul 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

🎯 Changes
Closes #1227.
Problem: The documented option
shouldAdjustScrollPositionOnItemSizeChangeis dead code. Passing it to a virtualizer has no effect:resizeItemnever sees it.Root cause:
resizeItemreadsthis.shouldAdjustScrollPositionOnItemSizeChange— an instance field thatsetOptionsnever assigns — and the option is missing fromVirtualizerOptionsentirely. The CHANGELOG (around line 110) documents the option as public API, so this is a wiring bug rather than a design change.Fix: Adds
shouldAdjustScrollPositionOnItemSizeChangetoVirtualizerOptions, and makesresizeItemread it options-first with a fallback to the instance field for backward compatibility with code that assigned the field directly.Testing: 3 new tests — overriding the default backward-scroll adjustment, the predicate receiving
(item, delta, instance), and returningfalsesuppressing the default adjustment. 122/122 vitest passing;tsc, eslint and prettier clean.Scope note: The issue also asks to revisit the backward-skip default behavior (part 2). This PR deliberately does not touch that — it only wires the documented option so users can opt out today. The default-behavior discussion can proceed separately.
✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit
New Features
Bug Fixes