table icon indicating copy to clipboard operation
table copied to clipboard

fix: The fixed attribute does not take effect

Open yezhonghu0503 opened this issue 1 year ago • 6 comments

修复表格expandable中设置fixed:right不生效,issues:https://github.com/ant-design/ant-design/issues/50846

  • 问题原因

对于fixed的处理不正确,一个是判断逻辑有问题,fixed不应该和expandIconColumnIndex一起判断,一个是插入扩展列的时候没有按照fixed的值来处理

  • 如何修复
  1. 插入时增加判断,当设置fixed为left或者,fixed没设置时,默认插入到列数据数组第一个,如果fixed为right则插入到最后一个
  2. 修改fixedColumn变量表达传入位置到逻辑

Summary by CodeRabbit

  • 新功能
    • 增强了列管理的灵活性,允许更动态地处理展开列的位置和列的固定状态。

yezhonghu0503 avatar Sep 21 '24 09:09 yezhonghu0503

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 Oct 28, 2024 3:06pm

vercel[bot] avatar Sep 21 '24 09:09 vercel[bot]

Walkthrough

此次更改涉及useColumns函数的逻辑修改,主要集中在插入展开列和确定列的固定位置的逻辑。更新后的条件允许在更多场景下插入展开列,并简化了确定固定列的逻辑,以提高列管理的灵活性。此外,新增的测试用例确保了固定列在可展开行中的正确行为。

Changes

文件路径 更改摘要
src/hooks/useColumns/index.tsx 修改了插入展开列的逻辑和固定列的确定方式,增强了列管理的灵活性。
tests/ExpandRow.spec.jsx 新增了测试用例以验证固定列在可展开行中的行为,并修改了现有测试以覆盖固定列的渲染。

Possibly related PRs

  • #1195: 此PR增强了expandedRowClassName属性以接受字符串,这与主PR中涉及的可展开行及其类名的处理相关。

Suggested reviewers

  • zombieJ
  • MadCcc

Poem

在列中跳跃的小兔子,
展开新列乐无比。
固定位置随心变,
灵活管理乐无边。
代码更新如春风,
兔子欢跳乐融融! 🐇✨


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?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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.

coderabbitai[bot] avatar Sep 21 '24 09:09 coderabbitai[bot]

搞个测试用例 cover 一下

afc163 avatar Sep 21 '24 12:09 afc163

搞个测试用例 cover 一下

ok,稍等

yezhonghu0503 avatar Sep 21 '24 15:09 yezhonghu0503

看了下测试用例,没考虑到expandIconColumnIndex小于0时是不渲染的,修改了一下判断条件

yezhonghu0503 avatar Sep 21 '24 16:09 yezhonghu0503

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 97.75%. Comparing base (26f9746) to head (38d1147). Report is 7 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1193   +/-   ##
=======================================
  Coverage   97.75%   97.75%           
=======================================
  Files          75       75           
  Lines        7484     7404   -80     
  Branches     1121     1124    +3     
=======================================
- Hits         7316     7238   -78     
+ Misses        162      160    -2     
  Partials        6        6           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Sep 22 '24 09:09 codecov[bot]

搞个测试用例 cover 一下

佬,这个pr为啥还不给合并捏

yezhonghu0503 avatar Sep 30 '24 07:09 yezhonghu0503

最好还是单独给个用例,单看 snap 的改变不容易看出是不是符合预期。

afc163 avatar Sep 30 '24 07:09 afc163

最好还是单独给个用例,单看 snap 的改变不容易看出是不是符合预期。

哦哦,明白鸟

yezhonghu0503 avatar Sep 30 '24 08:09 yezhonghu0503