-
-
Notifications
You must be signed in to change notification settings - Fork 593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: rc-component/table #1219
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
概述演练这个拉取请求主要涉及从 变更
序列图sequenceDiagram
participant Dev as 开发者
participant Table as Table组件
participant Util as @rc-component/util
Dev->>Table: 配置表格
Table->>Util: 请求工具函数
Util-->>Table: 返回工具函数
Table->>Dev: 渲染表格
可能相关的 PR
建议的审阅者
诗歌
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🔇 Additional comments (2)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
src/Table.tsx (1)
Line range hint
530-532
: 修复可能的TypeError
错误在第 530-532 行,
scrollBodyRef.current
可能为 undefined,直接使用会导致TypeError
,正如流水线失败日志所示。建议在使用前添加空值检查。提供以下代码修改以修复此问题:
if (horizonScroll && scrollBodyRef.current) { - onInternalScroll({ - currentTarget: getDOM(scrollBodyRef.current) as HTMLElement, + const currentTarget = getDOM(scrollBodyRef.current) as HTMLElement; + if (currentTarget) { + onInternalScroll({ + currentTarget, scrollLeft: scrollBodyRef.current?.scrollLeft, }); + } } else { setPingedLeft(false); setPingedRight(false); }
🧹 Nitpick comments (3)
src/stickyScrollBar.tsx (3)
61-63
: 移除不必要的event.persist()
调用在
onMouseDown
函数中调用了event.persist()
,但在现代 React 中已不再需要。建议移除此调用。提供以下代码修改:
const onMouseDown = (event: React.MouseEvent) => { - event.persist(); refState.current.delta = event.pageX - scrollState.scrollLeft; refState.current.x = 0; setActive(true); event.preventDefault(); };
Line range hint
69-81
: 为onMouseMove
事件参数指定正确的类型
onMouseMove
函数的事件参数当前类型为any
,建议将其明确为MouseEvent
类型,增强类型安全性。提供以下代码修改:
- const onMouseMove = (event: any) => { + const onMouseMove = (event: MouseEvent) => { // ... }
79-81
: 简化left
计算表达式在计算
left
时,存在冗余运算,可以简化为:提供以下代码修改:
- let left = refState.current.x + event.pageX - refState.current.x - refState.current.delta; + let left = event.pageX - refState.current.delta;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (27)
docs/examples/animation.tsx
(1 hunks)package.json
(2 hunks)src/Cell/index.tsx
(1 hunks)src/Cell/useCellRender.ts
(1 hunks)src/FixedHolder/index.tsx
(1 hunks)src/Table.tsx
(2 hunks)src/VirtualTable/index.tsx
(1 hunks)src/hooks/useColumns/index.tsx
(1 hunks)src/hooks/useExpand.ts
(1 hunks)src/hooks/useFixedInfo.ts
(1 hunks)src/hooks/useRowInfo.tsx
(1 hunks)src/hooks/useSticky.ts
(1 hunks)src/stickyScrollBar.tsx
(6 hunks)src/utils/legacyUtil.ts
(1 hunks)src/utils/offsetUtil.ts
(1 hunks)tests/Deprecated.spec.jsx
(1 hunks)tests/ExpandRow.spec.jsx
(1 hunks)tests/FixedColumn-IE.spec.jsx
(1 hunks)tests/FixedColumn.spec.tsx
(1 hunks)tests/FixedHeader.spec.jsx
(1 hunks)tests/Hover.spec.tsx
(1 hunks)tests/Scroll.spec.jsx
(1 hunks)tests/Sticky.spec.jsx
(1 hunks)tests/Table.spec.jsx
(1 hunks)tests/Virtual.spec.tsx
(1 hunks)tests/refs.spec.tsx
(1 hunks)tests/setup.ts
(1 hunks)
✅ Files skipped from review due to trivial changes (23)
- tests/FixedColumn.spec.tsx
- src/hooks/useColumns/index.tsx
- tests/Deprecated.spec.jsx
- src/Cell/index.tsx
- tests/Scroll.spec.jsx
- tests/Table.spec.jsx
- src/utils/legacyUtil.ts
- docs/examples/animation.tsx
- src/VirtualTable/index.tsx
- tests/refs.spec.tsx
- src/hooks/useExpand.ts
- src/FixedHolder/index.tsx
- src/hooks/useRowInfo.tsx
- tests/ExpandRow.spec.jsx
- src/hooks/useFixedInfo.ts
- tests/Hover.spec.tsx
- src/utils/offsetUtil.ts
- tests/FixedColumn-IE.spec.jsx
- tests/FixedHeader.spec.jsx
- src/hooks/useSticky.ts
- tests/Sticky.spec.jsx
- src/Cell/useCellRender.ts
- tests/Virtual.spec.tsx
🧰 Additional context used
🪛 GitHub Actions: ✅ test
src/Table.tsx
[error] 530-532: TypeError: Cannot read properties of undefined (reading 'width'). The error occurs when trying to access width property of scrollBodyRef.current or scrollBodyContainerRef which is undefined.
🔇 Additional comments (8)
src/Table.tsx (2)
30-36
: 新的导入语句正确更新导入语句已更新为使用新的
@rc-component/util
库,配置看起来正确。
78-78
: 验证getDOM
导入路径的正确性请确认从
@rc-component/util/lib/Dom/findDOMNode
导入的getDOM
函数路径是否正确,以确保模块路径和函数名准确无误。tests/setup.ts (1)
10-10
: 确认模拟模块的导入路径已将模拟的模块路径更改为
@rc-component/util/lib/getScrollBarSize
,请确认此路径和模块名称正确,确保测试能够正常运行。src/stickyScrollBar.tsx (4)
3-3
: 更新getScrollBarSize
的导入路径将
getScrollBarSize
的导入路径更新为@rc-component/util/lib/getScrollBarSize
,看起来正确。
7-7
: 更新raf
的导入路径将
raf
的导入路径更新为@rc-component/util/lib/raf
,看起来正确。
10-14
: 引入事件名称常量提高可读性将事件名称提取为常量,提高了代码的可读性和维护性。
141-149
: 确认使用document.body
添加事件监听器的适用性在添加和移除事件监听器时,使用了
document.body
。请确认在所有目标浏览器中,这样的使用方式都能正常工作。如有必要,考虑改为使用document
。package.json (1)
58-58
: 依赖包更新提醒将
rc-util
替换为@rc-component/util
是一个重要变更:
- 请确保新包
@rc-component/util
提供了与rc-util
相同的功能- 建议添加相关测试用例验证功能完整性
运行以下脚本检查依赖变更的影响:
✅ Verification successful
依赖迁移验证完成
经过代码扫描,确认:
- 已完全移除
rc-util
的引用@rc-component/util
的功能已被正确使用- 所有相关导入都已更新
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # 检查是否还有遗留的 rc-util 导入 rg "from 'rc-util" || rg "from \"rc-util" # 检查是否所有 @rc-component/util 的导入都是有效的 rg "from '@rc-component/util" || rg "from \"@rc-component/util"Length of output: 3661
New, updated, and removed dependencies detected. Learn more about Socket for GitHub ↗︎
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1219 +/- ##
==========================================
- Coverage 97.76% 97.76% -0.01%
==========================================
Files 76 76
Lines 7443 7441 -2
Branches 1128 1128
==========================================
- Hits 7277 7275 -2
Misses 160 160
Partials 6 6 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
package.json
(2 hunks)
🔇 Additional comments (2)
package.json (2)
Line range hint
2-58
: 重大变更缺少必要文档说明CHANGELOG.md 需要更新以下重要内容:
- 包名从
rc-table
变更为@rc-component/table
的说明- 版本从
7.50.2
降至1.0.0-0
的破坏性变更详情- 从
rc-util
迁移至@rc-component/util
的迁移指南建议:
- 更新 CHANGELOG.md,添加 1.0.0 版本的完整变更记录
- 添加迁移指南,详细说明 API 变更和依赖更新步骤
- 考虑创建单独的 MIGRATION.md 文件
58-58
: 依赖包迁移需要同步更新将工具库从
rc-util
迁移至@rc-component/util
是一个重要变更。请确保:
- 所有使用
rc-util
的代码都已更新- 新的依赖版本
^1.1.0
包含所需的所有功能✅ Verification successful
依赖迁移已完成且使用正确
经验证,代码库中已完全迁移至
@rc-component/util
:
- 所有原
rc-util
的引用已被移除- 新包
@rc-component/util
已在源码、测试和文档中得到广泛使用- 版本
^1.1.0
满足当前使用需求🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # 检查是否还有遗留的 rc-util 引用 rg "from 'rc-util" -l rg "from \"rc-util" -lLength of output: 50
Script:
#!/bin/bash # Check if rc-util is still in package.json grep -A 1 -B 1 "rc-util" package.json # Broader search for any rc-util references rg "rc-util" -l # Check usage of new package rg "@rc-component/util" -l # Check actual imports from new package ast-grep --pattern 'import $_ from "@rc-component/util"'Length of output: 771
"name": "@rc-component/table", | ||
"version": "1.0.0-0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
包名和版本号的重大变更需要谨慎处理
这些变更将对所有依赖项目产生重大影响:
- 包名从
rc-table
变更为@rc-component/table
- 版本从
7.50.2
降至1.0.0-0
建议:
- 确保已完成全面的测试
- 提供详细的迁移文档
- 考虑使用 alpha/beta 版本进行过渡
Summary by CodeRabbit
发行说明
新功能
rc-table
更改为@rc-component/table
summary
属性,允许自定义渲染表格摘要依赖变更
rc-util
迁移到@rc-component/util
@rc-component/util
依赖,移除了rc-util
版本更新
7.50.2
更改为1.0.0
这些更改主要涉及包的重组和依赖管理,对用户的影响相对较小。