Skip to content

[codex] expose scrollTop in extraRender info#357

Merged
zombieJ merged 4 commits into
masterfrom
codex/extra-render-scroll-top
May 18, 2026
Merged

[codex] expose scrollTop in extraRender info#357
zombieJ merged 4 commits into
masterfrom
codex/extra-render-scroll-top

Conversation

@zombieJ
Copy link
Copy Markdown
Member

@zombieJ zombieJ commented May 18, 2026

Summary

  • Add scrollTop to ExtraRenderInfo so extraRender consumers can position overlay content against the current vertical scroll offset without reading DOM or stale refs.
  • Pass the current internal offsetTop as scrollTop when building the extraRender info object.
  • Cover the new field with a scroll test.

Validation

  • npm test -- scroll.test.js --runInBand
  • npm run lint (passes with existing warnings)

Summary by CodeRabbit

发布说明

  • 新功能

    • 额外渲染回调现已提供滚动距离信息,支持基于滚动位置的动态渲染
    • 新增类型导出,提供更完整的 API 接口
  • 文档

    • 更新接口文档注释,完善滚动相关信息说明
  • 测试

    • 添加滚动功能测试用例,验证新增功能正确性

Review Change Stack

@vercel
Copy link
Copy Markdown

vercel Bot commented May 18, 2026

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

Project Deployment Actions Updated (UTC)
virtual-list Ready Ready Preview, Comment May 18, 2026 8:02am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 18, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 25bc614e-581e-47f1-baeb-122232a4f4a6

📥 Commits

Reviewing files that changed from the base of the PR and between 402e156 and eadf178.

📒 Files selected for processing (9)
  • src/List.tsx
  • src/ScrollBar.tsx
  • src/hooks/useFrameWheel.ts
  • src/hooks/useMobileTouchMove.ts
  • src/hooks/useScrollDrag.ts
  • src/hooks/useScrollTo.tsx
  • src/index.ts
  • src/interface.ts
  • tests/scroll.test.js

Walkthrough

本 PR 统一了多个文件对 @rc-component/util 依赖的导入方式,将其从内部路径改为主模块命名导入,同时在 List 组件的 extraRender 回调中新增 scrollTop 字段,增强了渲染信息的丰富度。此外扩展了库的公开 API 导出。

Changes

Virtual List scrollTop 特性与导入统一

Layer / File(s) Summary
依赖导入统一为命名导入
src/ScrollBar.tsx, src/hooks/useFrameWheel.ts, src/hooks/useMobileTouchMove.ts, src/hooks/useScrollDrag.ts, src/hooks/useScrollTo.tsx, src/List.tsx
rafuseLayoutEffectwarning 等工具函数从 @rc-component/util/lib/... 的内部路径改为从 @rc-component/util 主模块的命名导入,统一依赖引入方式。
extraRender 回调中添加 scrollTop 字段
src/List.tsx
extraRender 回调传入的 info 对象中新增 scrollTop 字段(值为当前 offsetTop),使额外渲染内容可基于滚动顶部偏移获取更多信息。
接口文档与功能测试
src/interface.ts, tests/scroll.test.js
补充 ExtraRenderInfooffsetXscrollTop 字段的 JSDoc 注释,并新增测试用例验证调用 scrollTo(80)extraRender 回调正确接收 scrollTop: 80 参数。
公开 API 导出扩展
src/index.ts
新增 ScrollConfigScrollTo 类型的重新导出,并引入 MockList 作为 ./mock 默认导出的别名。

🎯 2 (Simple) | ⏱️ ~12 分钟

Possibly related PRs

  • react-component/virtual-list#293:两个 PR 都修改了 src/List.tsx 关于列表滚动顶部偏移的行为——主 PR 在 extraRenderinfo.scrollTop 中添加信息源(来自 offsetTop),而该 PR 则引入 useScrollDrag 在拖动滚动期间调整 offsetTop,影响相同的 scrollTop 源。
  • react-component/virtual-list#351:主 PR 与 #351 通过更新 src/List.tsx/hooks 的导入路径使用 @rc-component/util 有重叠,但主 PR 另外在 extraRenderinfo 对象中新增了 scrollTop 字段。

Suggested reviewers

  • afc163

🐰 小白兔的贺诗:

依赖路径整顿齐,导入统一真清爽;
scrollTop 新信息送,渲染回调更内涵。
公开接口绽光彩,虚拟列表更精彩!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题清晰准确地总结了主要变更:在 extraRender 回调的信息对象中暴露 scrollTop 字段,使消费者可基于当前垂直滚动偏移量定位叠加层内容。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 codex/extra-render-scroll-top

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/List.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Cannot read config file: /.eslintrc.js
Error: Cannot find module '@umijs/fabric/dist/eslint'
Require stack:

  • /.eslintrc.js
  • /node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/bin/eslint.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1476:15)
    at wrapResolveFilename (node:internal/modules/cjs/loader:1049:27)
    at defaultResolveImplForCJSLoading (node:internal/modules/cjs/loader:1073:10)
    at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1094:12)
    at Module._load (node:internal/modules/cjs/loader:1262:25)
    at wrapModuleLoad (node:internal/modules/cjs/loader:255:19)
    at Module.require (node:internal/modules/cjs/loader:1576:12)
    at require (node:internal/modules/helpers:153:16)
    at Object. (/.eslintrc.js:1:14)
    at Module._compile (node:internal/modules/cjs/loader:1830:14)
src/hooks/useFrameWheel.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Cannot read config file: /.eslintrc.js
Error: Cannot find module '@umijs/fabric/dist/eslint'
Require stack:

  • /.eslintrc.js
  • /node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/bin/eslint.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1476:15)
    at wrapResolveFilename (node:internal/modules/cjs/loader:1049:27)
    at defaultResolveImplForCJSLoading (node:internal/modules/cjs/loader:1073:10)
    at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1094:12)
    at Module._load (node:internal/modules/cjs/loader:1262:25)
    at wrapModuleLoad (node:internal/modules/cjs/loader:255:19)
    at Module.require (node:internal/modules/cjs/loader:1576:12)
    at require (node:internal/modules/helpers:153:16)
    at Object. (/.eslintrc.js:1:14)
    at Module._compile (node:internal/modules/cjs/loader:1830:14)
src/hooks/useMobileTouchMove.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Cannot read config file: /.eslintrc.js
Error: Cannot find module '@umijs/fabric/dist/eslint'
Require stack:

  • /.eslintrc.js
  • /node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/bin/eslint.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1476:15)
    at wrapResolveFilename (node:internal/modules/cjs/loader:1049:27)
    at defaultResolveImplForCJSLoading (node:internal/modules/cjs/loader:1073:10)
    at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1094:12)
    at Module._load (node:internal/modules/cjs/loader:1262:25)
    at wrapModuleLoad (node:internal/modules/cjs/loader:255:19)
    at Module.require (node:internal/modules/cjs/loader:1576:12)
    at require (node:internal/modules/helpers:153:16)
    at Object. (/.eslintrc.js:1:14)
    at Module._compile (node:internal/modules/cjs/loader:1830:14)
  • 6 others

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 and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.48%. Comparing base (402e156) to head (eadf178).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #357   +/-   ##
=======================================
  Coverage   97.48%   97.48%           
=======================================
  Files          19       19           
  Lines         796      796           
  Branches      193      193           
=======================================
  Hits          776      776           
  Misses         20       20           

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the scrollTop property to the ExtraRenderInfo interface and ensures it is correctly passed to the extraRender function within the RawList component. A new test case has been added to verify that the vertical scroll offset is accurately reported. I have no feedback to provide as there were no review comments.

@zombieJ zombieJ force-pushed the codex/extra-render-scroll-top branch from e6819e7 to eadf178 Compare May 18, 2026 08:00
@zombieJ zombieJ marked this pull request as ready for review May 18, 2026 08:03
@zombieJ zombieJ merged commit ce756b6 into master May 18, 2026
12 checks passed
@zombieJ zombieJ deleted the codex/extra-render-scroll-top branch May 18, 2026 08:37
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