-
-
Notifications
You must be signed in to change notification settings - Fork 610
fix: Table rtl related className #1245
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Walkthrough此 PR 更新了表格组件中固定列的逻辑。主要调整包括将固定列属性判断由原来的 "left"/"right" 修改为 "start"/"end",并引入可选链以提高安全性。在 Changes
Sequence Diagram(s)sequenceDiagram
participant T as Table组件
participant UC as useColumns钩子
participant FU as fixUtil工具
T->>UC: 请求扁平化列数据
UC->>FU: 调用 isFixedStart/isFixedEnd 检查固定位置
FU-->>UC: 返回固定状态('start' 或 'end')
UC-->>T: 返回转换后的列定义
T->>T: 渲染表格,应用新固定列逻辑
Possibly related PRs
Suggested reviewers
Poem
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
tests/ExpandRow.spec.jsxOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the config "prettier" to extend from. Please check that the name of the config is correct. The config "prettier" was referenced from the config file in "/.eslintrc.js". If you still have problems, please stop by https://eslint.org/chat/help to chat with the team. 📜 Recent review detailsConfiguration used: CodeRabbit UI ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
🔇 Additional comments (1)
✨ Finishing Touches
🪧 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: 0
🧹 Nitpick comments (1)
tests/Table.spec.jsx (1)
622-622
: 添加了调试日志在测试中添加了
console.log(container.innerHTML);
语句,用于调试固定列和表头的渲染结果。由于这是测试代码,并且有助于开发过程中的调试,这个添加是合理的。不过发布到生产环境前应考虑移除它,以避免不必要的控制台输出。考虑在 PR 合并前删除此调试语句,或者使用条件语句包裹(例如通过环境变量控制):
- console.log(container.innerHTML); + if (process.env.DEBUG_TABLE) { + console.log(container.innerHTML); + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
tests/__snapshots__/FixedColumn.spec.tsx.snap
is excluded by!**/*.snap
tests/__snapshots__/Table.spec.jsx.snap
is excluded by!**/*.snap
📒 Files selected for processing (4)
src/Table.tsx
(2 hunks)src/hooks/useColumns/index.tsx
(3 hunks)src/utils/fixUtil.ts
(1 hunks)tests/Table.spec.jsx
(1 hunks)
🔇 Additional comments (8)
src/utils/fixUtil.ts (2)
19-19
: 将 fixed 属性判断简化为 start函数
isFixedStart
的实现已更改为仅检查column.fixed === 'start'
,不再判断'left'
值。这样的修改使代码更加清晰,并与其他文件中的更改保持一致。这一更改简化了逻辑,并支持了 RTL 布局的需求。
22-22
: 将 fixed 属性判断简化为 end函数
isFixedEnd
的实现已更改为仅检查column.fixed === 'end'
,不再判断'right'
值。这种更改与isFixedStart
的修改一致,使逻辑更加统一。这一更改使参数处理更加统一,并支持了 RTL 布局的需求。
src/hooks/useColumns/index.tsx (4)
66-67
: 更新 fixed 属性的解析逻辑此更改将列的
fixed
属性统一转换为'start'
或'end'
:
- 当
fixed
为true
或'left'
时转换为'start'
- 当
fixed
为'right'
时转换为'end'
这种更改更符合逻辑,使代码不再依赖于方向性术语,而是使用位置性术语,从而更好地支持 RTL 布局。
这个更改是对 API 实现的改进,使其更加语义化和一致。还使用了三元运算符进行简洁的表达,代码质量良好。
160-164
: 更新 expandColIndex 条件判断该条件判断现在考虑了
fixed === 'start'
和fixed === 'left'
,保持了向后兼容性,同时支持了新的属性值。这个更新确保了在使用新的
'start'
属性值时,展开列依然能够正确插入。
166-166
: 更新 expand 列的右侧固定条件修改了对
'right'
固定列的判断,同时支持'end'
属性值,确保了与上面更改的一致性。这一修改正确地处理了
'end'
属性值,保持了代码逻辑的一致性。
254-258
: 简化 flattenColumns 调用移除了对
revertForRtl
函数的调用,简化了列扁平化的逻辑。这与使用'start'
和'end'
代替方向性术语'left'
和'right'
的更改相一致,不再需要基于 RTL 方向进行特殊处理。这种简化使代码更加清晰,减少了不必要的逻辑分支,有利于代码维护。
src/Table.tsx (2)
778-779
: 更新固定列的 className 条件判断
- 修改了
${prefixCls}-has-fix-start
类名的条件,使用可选链语法?.
检查第一列是否固定,这增加了代码的安全性- 修改了
${prefixCls}-has-fix-end
类名的条件,检查最后一列的fixed
属性是否为'end'
(而不是之前的'right'
)这两项更改与其他文件中的修改一致,使用位置术语替代了方向术语。
使用可选链语法提高了代码安全性,防止在
flattenColumns
为空时的潜在错误。更改类名判断条件也保持了与其他代码的一致性。
830-830
: 更新 allColumnsFixedLeft 的检查条件将
allColumnsFixedLeft
条件更新为检查所有列的fixed
属性是否为'start'
(而不是之前的'left'
),这与前面的更改保持一致。这个更改确保了表格上下文中的这一属性与新的位置性术语保持一致。
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1245 +/- ##
==========================================
- Coverage 98.02% 98.02% -0.01%
==========================================
Files 76 76
Lines 7399 7385 -14
Branches 1145 1138 -7
==========================================
- Hits 7253 7239 -14
Misses 140 140
Partials 6 6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary by CodeRabbit
Refactor
Tests