Skip to content
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

Fix rtl box-shadow effect #1237

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

yellowryan
Copy link

@yellowryan yellowryan commented Feb 27, 2025

fix ant-design/ant-design#52942

  • 相关代码改动
    1.对hasGapFixed方法进行了修改,确保在rtl模式下能正确判断。
    2.改动部分css,保证有在有间隔的固定列下,box-shadow不展示。

Summary by CodeRabbit

  • 样式

    • 调整了固定列的显示规则,扩展了隐藏效果,使更多单元格呈现预期样式。
  • 重构

    • 优化了检测固定列间隔的逻辑,新增对左右布局方向的支持,提升了代码结构和可维护性。
  • 测试

    • 新增并完善了验证固定列布局表现的测试,覆盖了不同配置和布局方向的使用场景。

Copy link

vercel bot commented Feb 27, 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 Feb 27, 2025 4:20am

Copy link

coderabbitai bot commented Feb 27, 2025

Walkthrough

本次提交涉及三个主要部分的更改:在 CSS 文件中修改了固定列的伪元素选择器,扩展了隐藏规则;在 useColumns 钩子中重构了固定列间隙判断逻辑,引入了辅助函数(findLastIndex、findFirstIndex 和 checkGap)并支持 RTL 与 LTR 布局;在测试文件中更新了固定列的配置,并增加了新的测试用例以验证特定布局下类名的存在性。

Changes

File Change Summary
assets/index.less 修改 &-fixed-column-gapped 类中的伪元素选择器,新增 .@{tablePrefixCls}-cell-fix-left-first::after.@{tablePrefixCls}-cell-fix-right-last::after,调整显示规则
src/hooks/useColumns/index.tsx 重构固定列间隙检测逻辑,使用 findLastIndexfindFirstIndexcheckGap 函数,更新依赖项,支持左右固定列和 RTL/LTR 布局
tests/FixedColumn.spec.tsx 更新 columns 数组中 title10 的配置(新增 width: 100fixed: 'right'),新增 RTL 布局下固定列类名存在性的测试用例

Sequence Diagram(s)

sequenceDiagram
    participant T as Table Component
    participant U as useColumns Hook
    participant L as Helper Functions
    participant C as checkGap Function

    T->>U: 调用 useColumns(..., direction)
    U->>L: 查找左侧与右侧固定列索引
    L-->>U: 返回索引信息
    U->>C: 检查固定列间隙 (基于direction)
    C-->>U: 返回间隙状态
    U-->>T: 返回更新后的列配置信息
Loading

Suggested reviewers

  • zombieJ
  • afc163

Poem

嗨,我是一只快乐的小兔,
代码跳跃似草原上的舞蹈,
CSS与逻辑齐齐跃动,
修正中的每一处都闪耀。
让我们一路向前,追寻更新的光芒!
🐰✨

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.

tests/FixedColumn.spec.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 77ac837 and c3bec76.

📒 Files selected for processing (1)
  • tests/FixedColumn.spec.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/FixedColumn.spec.tsx

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 generate docstrings to generate docstrings 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.

@yellowryan
Copy link
Author

antd中对应的issue中还有一个针对fixed的改动,感觉这块改动的话会影响很大,麻烦大佬们看下是否有必要。

@yellowryan yellowryan changed the title Fix rtl shadow effect Fix rtl box-shadow effect Feb 27, 2025
Copy link

@coderabbitai coderabbitai bot left a 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 (4)
tests/FixedColumn.spec.tsx (1)

379-385: 可在 LTR 场景下同样验证。

此测试用例检查在 RTL 模式下是否添加了 rc-table-fixed-column-gapped,建议补充 LTR 模式的断言,以确保阴影效果在双向布局中都能正确处理。

assets/index.less (1)

61-63: 谨慎使用 !important

本次改动中长度更广的选择器使用了 display: none !important;,能在一定范围内隐藏阴影元素。但若后续需要局部显示或局部覆盖,!important 会带来维护难度。建议在可行范围内尽量减少对 !important 的依赖。

src/hooks/useColumns/index.tsx (2)

290-290: 拼写错误小建议。

注释里 “dut” 建议更改为 “due”,以使语句在英文语境下表述更准确通顺。

- // dut to old browser not support `findLastIndex`
+ // due to old browsers not supporting `findLastIndex`

309-334: 避免重复调用,减少不必要的计算开销。

findLastIndex('left')findFirstIndex('left') 等函数的多次重复调用,会带来无谓的性能损耗。建议先存储结果至局部变量,然后在后续逻辑中服用该变量,提升可读性和运行效率。

-    const lastLeftIndex =
-      findLastIndex('left') !== -1 ? findLastIndex('left') : findLastIndex(true);
-    if (lastLeftIndex >= 0 && checkGap(0, lastLeftIndex, 'left')) {
+    const leftIndex = findLastIndex('left');
+    const trueIndex = findLastIndex(true);
+    const lastLeftIndex = leftIndex !== -1 ? leftIndex : trueIndex;
+    if (lastLeftIndex >= 0 && checkGap(0, lastLeftIndex, 'left')) {
       return true;
     }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d218893 and 77ac837.

⛔ Files ignored due to path filters (1)
  • tests/__snapshots__/FixedColumn.spec.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (3)
  • assets/index.less (1 hunks)
  • src/hooks/useColumns/index.tsx (1 hunks)
  • tests/FixedColumn.spec.tsx (2 hunks)
🔇 Additional comments (2)
tests/FixedColumn.spec.tsx (1)

53-53: 这个列配置看起来逻辑正确。

将列「title10」固定在表格右侧并设置宽度为 100,有助于保证与其他列的渲染一致性。

src/hooks/useColumns/index.tsx (1)

280-289: 提炼检查逻辑,增强可读性。

checkGap 函数将列区间的固定属性校验集中处理,使判断逻辑更加清晰,且便于日后扩展多固定列的需求。

Copy link

codecov bot commented Feb 27, 2025

Codecov Report

Attention: Patch coverage is 95.74468% with 2 lines in your changes missing coverage. Please review.

Project coverage is 97.75%. Comparing base (d218893) to head (77ac837).

Files with missing lines Patch % Lines
src/hooks/useColumns/index.tsx 95.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1237      +/-   ##
==========================================
- Coverage   97.77%   97.75%   -0.02%     
==========================================
  Files          76       76              
  Lines        7453     7480      +27     
  Branches     1132     1142      +10     
==========================================
+ Hits         7287     7312      +25     
- Misses        160      162       +2     
  Partials        6        6              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zombieJ
Copy link
Member

zombieJ commented Feb 27, 2025

Current Table shadow logic is little complete and not support stack columns. I have the plan to refactor of this. Let me handle it : )

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.

Fixed Columns Issues in RTL Mode
2 participants