Skip to content

fix: retry key scroll after data update - #377

Merged
zombieJ merged 1 commit into
masterfrom
agent/retry-unresolved-scroll-key
Jul 31, 2026
Merged

fix: retry key scroll after data update#377
zombieJ merged 1 commit into
masterfrom
agent/retry-unresolved-scroll-key

Conversation

@zombieJ

@zombieJ zombieJ commented Jul 31, 2026

Copy link
Copy Markdown
Member

Summary

Retry key-based scrolling while its target index is unresolved, allowing data added by a later layout update to be found.

Root cause

#376 retried key lookup only when a scroll measurement retry was already needed. If the target data appeared after the first layout pass, needCollectHeight stayed false and no retry was scheduled.

The previous regression test updated data in the same event batch as scrollTo, so the first layout pass already saw the target and did not expose this gap.

Changes

  • Continue retrying while the resolved index is negative
  • Update the regression test so data changes in a later layout effect

Test

  • Confirmed the updated regression test fails on master with scrollTop = 0
  • ut test -- tests/scroll.test.js --runInBand
  • ut test -- --runInBand
  • ut run tsc
  • eslint src/hooks/useScrollTo.tsx tests/scroll.test.js

Follow-up to #376. Related to ant-design/ant-design#58841.

Summary by CodeRabbit

  • Bug Fixes
    • 修复目标索引无效时滚动同步未触发高度收集的问题。
    • 优化数据更新后的滚动重试,确保布局完成后能够滚动到目标位置。
  • Tests
    • 增加布局变化后滚动位置校验,提升滚动行为的可靠性。

@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@vercel

vercel Bot commented Jul 31, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
virtual-list Ready Ready Preview Jul 31, 2026 6:29am

@github-actions

Copy link
Copy Markdown

React Doctor found no issues. 🎉

⚠️ Warning: .github/workflows/react-doctor.yml is configured incorrectly. See below to fix.

React Doctor compares against master to report only the issues this pull request introduces. This run couldn't complete that comparison (usually a shallow CI checkout with no merge base), so it listed every issue in the changed files, including ones that already existed on master.

Add fetch-depth: 0 to the actions/checkout step in .github/workflows/react-doctor.yml so the checkout includes the history React Doctor needs:

 jobs:
   react-doctor:
     steps:
       - uses: actions/checkout@v5
+        with:
+          fetch-depth: 0

       - uses: millionco/react-doctor@v2

To silence this warning, set silence-missing-baseline-warning: true on the React Doctor action.

Reviewed by React Doctor for commit 9741f0c.

@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.60%. Comparing base (8981cf6) to head (9741f0c).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #377      +/-   ##
==========================================
+ Coverage   96.88%   97.60%   +0.71%     
==========================================
  Files          19       19              
  Lines         836      836              
  Branches      209      209              
==========================================
+ Hits          810      816       +6     
+ Misses         26       20       -6     

☔ 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.

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown

❌ Deploy failed

PR preview ❌ Failed ❌ Failed
🔗 Preview https://react-component-virtual-list-preview-pr-377.surge.sh (may be unavailable)
📝 Commit9741f0c
🪵 LogsView logs
📋 Build log (last lines)
npm error
npm error Could not resolve dependency:
npm error peer eslint@"^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9.7" from eslint-plugin-react@7.37.5
npm error node_modules/eslint-plugin-react
npm error   dev eslint-plugin-react@"^7.37.5" from the root project
npm error   eslint-plugin-react@"^7.32.2" from @umijs/fabric@4.0.1
npm error   node_modules/@umijs/fabric
npm error     @umijs/fabric@"^4.0.0" from rc-test@7.1.3
npm error     node_modules/rc-test
npm error       dev rc-test@"^7.1.3" from the root project
npm error
npm error Conflicting peer dependency: eslint@9.39.5
npm error node_modules/eslint
npm error   peer eslint@"^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9.7" from eslint-plugin-react@7.37.5
npm error   node_modules/eslint-plugin-react
npm error     dev eslint-plugin-react@"^7.37.5" from the root project
npm error     eslint-plugin-react@"^7.32.2" from @umijs/fabric@4.0.1
npm error     node_modules/@umijs/fabric
npm error       @umijs/fabric@"^4.0.0" from rc-test@7.1.3
npm error       node_modules/rc-test
npm error         dev rc-test@"^7.1.3" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error /home/runner/.npm/_logs/2026-07-31T06_30_36_207Z-eresolve-report.txt
npm error A complete log of this run can be found in: /home/runner/.npm/_logs/2026-07-31T06_30_36_207Z-debug-0.log

🤖 Powered by surge-preview

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 71e6514e-240e-44f9-b40d-7957afeddf97

📥 Commits

Reviewing files that changed from the base of the PR and between 8981cf6 and 9741f0c.

📒 Files selected for processing (2)
  • src/hooks/useScrollTo.tsx
  • tests/scroll.test.js

Walkthrough

当目标索引无效时,滚动同步会继续收集高度。测试覆盖布局阶段扩展数据后重试 key scroll,并验证最终位置。

Changes

滚动同步重试

Layer / File(s) Summary
高度收集与布局后重试
src/hooks/useScrollTo.tsx, tests/scroll.test.js
目标索引小于零时将 needCollectHeight 初始化为 true。测试在 useLayoutEffect 中扩展数据,并验证最终滚动位置为 600

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: aojunhao123

Poem

小兔轻点滚动键,
无效索引不再眠。
高度收集跟布局,
数据变后再试遍。
目标位置六百见。

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/retry-unresolved-scroll-key

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@zombieJ
zombieJ marked this pull request as ready for review July 31, 2026 06:33
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@zombieJ
zombieJ merged commit e411005 into master Jul 31, 2026
12 checks passed
@zombieJ
zombieJ deleted the agent/retry-unresolved-scroll-key branch July 31, 2026 06:34
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.

1 participant