feat(react-virtualizer): Add improved scrollTo with iterative corrections for dynamic lists#573
Merged
dmytrokirpa merged 5 commits intomicrosoft:mainfrom Jan 27, 2026
Conversation
Contributor
|
I'd vote we can remove the old functionality since we're still in zero dot, once we can finalize the dynamic behavior we should be ready to move to 1.0 and stabilize the API without retaining deprecated functionality. |
Mitch-At-Work
approved these changes
Dec 3, 2025
Contributor
Mitch-At-Work
left a comment
There was a problem hiding this comment.
Looks good, I don't see any cause for concern in regards to Virtualizer recalcs and functionality works as expected - I do think we should remove the old API and enable this by default as we are still in preview (0.x.y) but will leave that up to you
mainframev
approved these changes
Dec 17, 2025
…ions for dynamic lists
5485bf5 to
3ff0fcf
Compare
47455ea to
619e22b
Compare
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.
Description
This PR introduces an improved
scrollToimplementation forVirtualizerScrollViewDynamicthat handles dynamically sized items more accurately. The new behavior is opt-in via theenableScrollToCorrectionsprop to ensure backward compatibility.Problem
When using
scrollTowith dynamically sized items in virtualized lists, the target element could end up misaligned or outside the viewport because:Current behavior: The scrollTo function does not navigate to the correct position.
https://microsoft.github.io/fluentui-contrib/react-virtualizer/?path=/story/packages-react-virtualizer-virtualizerscrollviewdynamic--scroll-to
Screen.Recording.2025-12-03.at.16.13.00.mov
Solution
Added a new
useScrollToItemDynamichook that provides:Screen.Recording.2025-12-03.at.16.14.41.mov
Changes
New Files
packages/react-virtualizer/src/hooks/useScrollToItemDynamic.ts- New hook for managing scroll-to operations with correctionsModified Files
packages/react-virtualizer/src/hooks/useMeasureList.ts- AddedonItemMeasuredcallback parameterpackages/react-virtualizer/src/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.tsx- Integrated new hook with opt-in behaviorpackages/react-virtualizer/src/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.types.ts- AddedenableScrollToCorrectionsproppackages/react-virtualizer/stories/VirtualizerScrollViewDynamic/ScrollTo.stories.tsx- Updated story to demonstrate new behaviorUsage
API
New Prop:
enableScrollToCorrectionsenableScrollToCorrectionsbooleanfalseWhen disabled (default): Uses legacy
scrollToItemDynamic- existing behavior unchanged.When enabled: Uses
useScrollToItemDynamichook which provides:useMeasureListscroll compensation during operationsTesting
enableScrollToCorrectionsis not setOpen questions
Should we mark the existing
scrollToDynamicItemutil asdeprecated(as we can't fix it or just remove)?