Skip to content

fix(virtual-scroll): align scrollToIndex with measured and compressed items - #2410

Merged
rkaraivanov merged 1 commit into
masterfrom
rkaraivanov/virtual-scroll-fixes
Sep 29, 2026
Merged

rkaraivanov merged 1 commit into
masterfrom
rkaraivanov/virtual-scroll-fixes

Conversation

@rkaraivanov

Copy link
Copy Markdown
Member

Description

layoutComplete resolved before the ResizeObserver measured the rendered items, because a frame runs its animation frame callbacks first. So scrollToIndex stopped its correction early. Wait for a task after each frame, and settle only after a frame with no render.

Under coordinate compression, the ratio of the sizes left the last items out of reach, and the content moved at DOM scale inside a window, so items landed tens of pixels off and jumped when the window moved. Map the scroll ranges onto each other, and move the content on each scroll while the list is compressed.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Checklist

  • My code follows the project's coding standards
  • I have tested my changes locally
  • I have added a CHANGELOG.md entry under [Unreleased]

… items

layoutComplete resolved before the ResizeObserver measured the rendered
items, because a frame runs its animation frame callbacks first. So
scrollToIndex stopped its correction early. Wait for a task after each
frame, and settle only after a frame with no render.

Under coordinate compression, the ratio of the sizes left the last items
out of reach, and the content moved at DOM scale inside a window, so
items landed tens of pixels off and jumped when the window moved. Map
the scroll ranges onto each other, and move the content on each scroll
while the list is compressed.
Copilot AI balanced review requested due to automatic review settings September 29, 2026 16:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Browser-specific frame timing and extreme-coordinate behavior warrant final human validation.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes virtual-scroll alignment after measurement and under coordinate compression.

Changes:

  • Waits for post-frame measurements before settling layout.
  • Maps virtual and DOM scroll ranges accurately.
  • Adds regression tests and documentation.
File Description
virtualization.ts Repositions content and improves layout settling.
virtualization.spec.ts Adds alignment and compression tests.
engine.ts Corrects compressed-coordinate calculations.
engine.spec.ts Tests revised engine mathematics.
spec.md Documents behavior and test scenarios.
CHANGELOG.md Records user-facing fixes.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@rkaraivanov
rkaraivanov merged commit 268701b into master Sep 29, 2026
8 checks passed
@rkaraivanov
rkaraivanov deleted the rkaraivanov/virtual-scroll-fixes branch September 29, 2026 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants