-
-
Notifications
You must be signed in to change notification settings - Fork 612
Fix fixed property not being inherited by children columns #1303
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
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Walkthrough本次更改调整了 Changes
Sequence Diagram(s)sequenceDiagram
participant 调用者
participant flatColumns
participant 子列
调用者->>flatColumns: 传入 columns
flatColumns->>flatColumns: 遍历每个 column
alt column 有 children
flatColumns->>子列: 检查子列 fixed 属性
alt 子列有 fixed
flatColumns->>子列: 保留子列 fixed
else
flatColumns->>子列: 继承父列 fixed
end
end
flatColumns-->>调用者: 返回扁平化后的 columns
Assessment against linked issues
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
src/hooks/useColumns/index.tsxOops! 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. ✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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)
src/hooks/useColumns/index.tsx (1)
74-74
: 变量名拼写错误。变量名
subColum
应该是subColumn
(缺少字母 'n')。建议修复拼写错误:
- ...flatColumns(subColumns, mergedKey).map(subColum => ({ + ...flatColumns(subColumns, mergedKey).map(subColumn => ({对应地,第76行也需要修改:
- fixed: subColum.fixed ?? parsedFixed, + fixed: subColumn.fixed ?? parsedFixed,
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/hooks/useColumns/index.tsx
(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: bbb169
PR: react-component/table#1202
File: src/Table.tsx:903-904
Timestamp: 2024-11-08T12:53:09.293Z
Learning: 在 `src/Table.tsx` 文件的 React 组件 `Table` 中,即使 `bodyScrollLeft` 频繁更新,也需要在 `TableContextValue` 的 `useMemo` 依赖数组中包含 `bodyScrollLeft` 和 `headerCellRefs`,因为每次滚动时重新计算 `TableContextValue` 是解决该问题所必须的。
src/hooks/useColumns/index.tsx (1)
Learnt from: bbb169
PR: react-component/table#1202
File: src/Table.tsx:903-904
Timestamp: 2024-11-08T12:53:09.293Z
Learning: 在 `src/Table.tsx` 文件的 React 组件 `Table` 中,即使 `bodyScrollLeft` 频繁更新,也需要在 `TableContextValue` 的 `useMemo` 依赖数组中包含 `bodyScrollLeft` 和 `headerCellRefs`,因为每次滚动时重新计算 `TableContextValue` 是解决该问题所必须的。
🔇 Additional comments (1)
src/hooks/useColumns/index.tsx (1)
74-77
: 逻辑修复正确,很好地解决了固定属性继承问题。这个修改正确地解决了子列固定属性不被父列覆盖的问题。使用空值合并运算符
??
确保:
- 如果子列已经定义了
fixed
属性,则保留其值- 如果子列没有定义
fixed
属性,则继承父列的parsedFixed
值这样既保持了向后兼容性,又修复了属性继承的逻辑错误。
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1303 +/- ##
=======================================
Coverage 95.71% 95.71%
=======================================
Files 57 57
Lines 3410 3410
Branches 660 661 +1
=======================================
Hits 3264 3264
Misses 121 121
Partials 25 25 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Fixes https://github.com/ant-design/ant-design/issues/51812
Similar issue: https://table-react-component.vercel.app/demo/fixed-columns-and-header-rtl
Applying to Fix Left and Fix title3 should make the parent column fixed as well as the children.
Due to misordering of the properties of the column, the fixed property isn't inherited from the parent due to property overriding from object spread.
Summary by CodeRabbit