Skip to content

Changes the order of fixed and other properties in flatColumns#1302

Closed
ryantang247 wants to merge 2 commits into
react-component:masterfrom
ryantang247:fixed-inherit
Closed

Changes the order of fixed and other properties in flatColumns#1302
ryantang247 wants to merge 2 commits into
react-component:masterfrom
ryantang247:fixed-inherit

Conversation

@ryantang247
Copy link
Copy Markdown
Contributor

@ryantang247 ryantang247 commented Jul 15, 2025

Fixes https://github.com/ant-design/ant-design/issues/51812

A similar issue can be found in the example from https://table-react-component.vercel.app/demo/fixed-columns-and-header-rtl, where Fix Left and Fix title3 should make the parent column fixed, but the child columns are not responding.

fixedColumnsAndHeaderRtl

In the function mentioned, the property wasn't inherited due to misordering of the properties of column.

Summary by CodeRabbit

  • 修复问题
    • 修正了列固定属性的优先级,确保父列的固定属性会覆盖子列的同名属性。

@vercel
Copy link
Copy Markdown

vercel Bot commented Jul 15, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
table ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 15, 2025 3:43am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jul 15, 2025

Walkthrough

本次更改调整了 flatColumns 函数中对子列(children columns)fixed 属性的赋值顺序。现在,父列的 fixed 属性会覆盖子列自身的 fixed 属性,从而确保当父列设置 fixed 时,其所有子列都能继承该固定属性。

Changes

文件/分组 变更摘要
src/hooks/useColumns/index.tsx 调整了 flatColumns 函数中 fixed 属性的赋值顺序,使父列的 fixed 属性覆盖子列的同名属性。

Sequence Diagram(s)

sequenceDiagram
    participant ParentColumn
    participant SubColumn
    participant flatColumns

    ParentColumn->>flatColumns: 传递 columns(含 fixed 属性)
    flatColumns->>SubColumn: 遍历 children,合并属性
    flatColumns-->>SubColumn: 用父列 fixed 覆盖子列 fixed
    flatColumns->>flatColumns: 返回合并后的列数组
Loading

Assessment against linked issues

Objective Addressed Explanation
修复有 children 的固定列无法整体固定在右侧 (#51812)

Suggested reviewers

  • zombieJ
  • afc163

Poem

小兔敲键盘,代码轻轻改,
固定属性传,父子不分开。
右侧齐整排,表格更精彩,
兔子乐开怀,Bug 说拜拜!
🐇✨

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/hooks/useColumns/index.tsx

Oops! 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 details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 57579f1 and a41b961.

📒 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 放在 ...subColum 之后,确保了父列的固定属性能够覆盖子列自身的固定属性,这符合预期的继承行为。

之前的实现中,子列的属性会覆盖父列的 fixed 属性,导致即使父列设置了 fixed,子列也可能不会表现为固定列。现在的实现确保了当父列设置为固定时,所有子列都会继承这个固定行为,这是更合理的默认行为。

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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