Skip to content

fix: Fix broken pointer scroll in virtual lists in certain situations - #5124

Merged
avinashbot merged 1 commit into
mainfrom
virtual-list-broken-scroll
Oct 9, 2026
Merged

avinashbot merged 1 commit into
mainfrom
virtual-list-broken-scroll

Conversation

@avinashbot

@avinashbot avinashbot commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Description

See ticket for repro and video. It's pretty easy to reproduce but hard to do by accident (open the thing with the keyboard and scroll with your mouse without moving your cursor). Turns out, it's because the return value of useVirtual isn't stable between renders, so we got accidental rerenders, and scrollToIndex got called unintentionally. Fixed it by only using scrollToIndex (made stable) inside the useEffect.

Related links, issue #, if available: AWSUI-62335

How has this been tested?

Tested in a dev page, verified that it works once I switch to the new implementation. Kiro wrote me some unit tests, but they were complex and mocked basically everything since JSDOM doesn't support a lot of measurement stuff. So integ tests it is (also written by Kiro).

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.71%. Comparing base (3b62c18) to head (f2bcfdd).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5124   +/-   ##
=======================================
  Coverage   97.70%   97.71%           
=======================================
  Files         990      991    +1     
  Lines       31818    31838   +20     
  Branches    11752    11758    +6     
=======================================
+ Hits        31089    31109   +20     
+ Misses        722      683   -39     
- Partials        7       46   +39     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@avinashbot
avinashbot added this pull request to the merge queue Oct 9, 2026
Merged via the queue into main with commit c41de07 Oct 9, 2026
69 checks passed
@avinashbot
avinashbot deleted the virtual-list-broken-scroll branch October 9, 2026 10:14

This branch was successfully deployed

3 active deployments
dev-pages-react16 — f2bcfdd0 Deployed Oct 9, 2026 by avinashbot via deploy (React 16) / deploy #2651
dev-pages-react18 — f2bcfdd0 Deployed Oct 9, 2026 by avinashbot via deploy (React 18) / deploy #2651
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