Skip to content

Conversation

@codewizardTM
Copy link
Contributor

@codewizardTM codewizardTM commented Nov 7, 2025

🤔 This is a ...

  • 🆕 New feature
  • 🐞 Bug fix
  • 📝 Site / documentation improvement
  • 📽️ Demo improvement
  • 💄 Component style improvement
  • 🤖 TypeScript definition improvement
  • 📦 Bundle size optimization
  • ⚡️ Performance optimization
  • ⭐️ Feature enhancement
  • 🌐 Internationalization
  • 🛠 Refactoring
  • 🎨 Code style optimization
  • ✅ Test Case
  • 🔀 Branch merge
  • ⏩ Workflow
  • ⌨️ Accessibility improvement
  • ❓ Other (about what?)

🔗 Related Issues

fix ant-design/ant-design#55310


💡 Background and Solution

In some cases, due to precision issues, the maximum value of the scroll container’s scrollLeft may still be less than scrollWidth - clientWidth.
To handle this, we subtract 1 from scrollWidth - clientWidth to smooth out the precision discrepancy.
Before:
Before
After
After


📝 Change Log

Language Changelog
🇺🇸 English Fix the issue where the fixed column shadow remains visible due to precision errors
🇨🇳 Chinese 修复因为精度问题导致的固定列阴影一直存在的问题

Summary by CodeRabbit

发布说明

  • 错误修复
    • 修正了表格末端固定列阴影的显示条件,避免在边界情况下错误地显示或隐藏阴影。
    • 微调了水平滚动时末端阴影的触发时机,使阴影显示更精确、视觉更一致。

…ollable width, causing the shadow to remain visible
@vercel
Copy link

vercel bot commented Nov 7, 2025

Someone is attempting to deploy a commit to the React Component Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link

coderabbitai bot commented Nov 7, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

调整表格固定列右侧阴影的显示阈值:在 Cell 组件中将 end-fixed 阴影判断从 >=1 改为 >1(即需严格大于 1),在 Table 组件中将横向滚动判断向内收 1 像素(absScrollStart < scrollWidth - clientWidth - 1)。

Changes

Cohort / File(s) 变更摘要
固定列单元格阴影阈值
src/Cell/index.tsx
将 end-fixed 单元格的 showEndShadow 计算由 (offsetFixedEndShadow >= 1) 改为 (offsetFixedEndShadow > 1),使阈值为严格大于 1
表格横向滚动阴影触发
src/Table.tsx
调整横向滚动端点判断:absScrollStart < scrollWidth - clientWidth - 1(原为 < scrollWidth - clientWidth),使 end-shadow 的触发点向内移动 1 像素

Sequence Diagram(s)

sequenceDiagram
    participant User as 用户
    participant Table as Table 组件
    participant Cell as Cell 单元格渲染

    note over User,Table `#f3f4f6`: 用户横向滚动表格
    User->>Table: 触发 scroll 事件 (absScrollStart)
    Table->>Table: 计算是否显示右侧固定列阴影\n检查 absScrollStart < scrollWidth - clientWidth - 1
    alt 显示 end-shadow
        Table->>Cell: 传递 end-shadow 可见性
        Cell->>Cell: 计算 offsetFixedEndShadow (> 1)
        Cell->>Table: 渲染带阴影的固定列
    else 隐藏 end-shadow
        Table->>Cell: 传递 end-shadow 不可见
        Cell->>Table: 渲染无阴影的固定列
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • 改动为边界/阈值微调,逻辑简单且集中在少数文件。
  • 需要重点关注:
    • src/Cell/index.tsx 中由 >=1 改为 >1 的边界语义是否覆盖所有浏览器像素舍入场景;
    • src/Table.tsx 中 -1 像素的调整在不同滚动模式(如 scroll={{ x: 'max-content' }}) 下是否仍然满足期望行为。

Possibly related PRs

Suggested reviewers

  • zombieJ

Poem

🐰 侧影轻轻去,像素正中来,
滚到尽头不留痕,细微处见裁量,
兔兔轻敲一行改,表格整洁又自在。 ✨

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确反映了PR的主要变更——解决由精度问题导致的阴影保持可见的bug。
Linked Issues check ✅ Passed 代码变更通过在水平滚动条计算中减1来解决精度问题,使阴影在滚动到最右端时正确消失,符合#55310的需求。
Out of Scope Changes check ✅ Passed 所有变更都专注于修复固定列阴影问题,没有发现超出范围的改动。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 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 b09a58d and 2e325da.

📒 Files selected for processing (1)
  • src/Cell/index.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Cell/index.tsx

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @codewizardTM, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a persistent visual bug in tables where fixed column shadows would incorrectly remain visible even when the table was scrolled to its absolute end. The root cause was identified as floating-point precision limitations in scrollLeft calculations, which prevented the scroll position from exactly matching the maximum scrollable width. The solution introduces a minor adjustment to the scroll boundary detection, adding a small tolerance to ensure shadows disappear as expected when the content is fully scrolled.

Highlights

  • Precision Issue Fix: Addresses a bug where floating-point precision issues prevented scrollLeft from reaching its maximum value, causing fixed column shadows to remain visible even when the table was fully scrolled.
  • Scroll Boundary Adjustment: Modifies the calculation for determining the end scroll position by subtracting 1 from scrollWidth - clientWidth to account for these precision discrepancies, ensuring the shadow correctly disappears.
  • Shadow Visibility Threshold: Adjusts the threshold for showing the end shadow in src/Cell/index.tsx from >= 1 to >= 2, further refining the condition for shadow disappearance.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses a bug where fixed column shadows remain visible due to floating-point precision issues in scroll position calculations. The fix introduces a buffer when checking if the scroll has reached the end. The change in Table.tsx seems correct. However, I've noticed a potential inconsistency in the threshold used in Cell/index.tsx compared to Table.tsx, which could lead to visual discrepancies. My review includes a comment to address this.

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 (2)
src/Table.tsx (1)

510-510: 修复精度问题的正确方案

此改动通过减去 1 像素来容忍浮点数精度误差,当滚动位置在最大值 1 像素范围内时隐藏阴影。这与 src/Cell/index.tsx 第 167 行的改动(从 >= 1 改为 >= 2)协调一致,有效解决了阴影始终可见的问题。

可选改进:考虑将魔法数字 1 提取为命名常量(如 SCROLL_PRECISION_THRESHOLD)并添加注释说明精度问题,以提高代码可维护性:

+// Threshold to accommodate floating-point precision issues in scroll position
+const SCROLL_PRECISION_THRESHOLD = 1;
+
 const onInternalScroll = useEvent(
   ({ currentTarget, scrollLeft }: { currentTarget: HTMLElement; scrollLeft?: number }) => {
     // ...
     setShadowStart(absScrollStart > 0);
-    setShadowEnd(absScrollStart < scrollWidth - clientWidth - 1);
+    setShadowEnd(absScrollStart < scrollWidth - clientWidth - SCROLL_PRECISION_THRESHOLD);
   }
 );
src/Cell/index.tsx (1)

167-167: 修复精度问题的阈值调整

将阈值从 >= 1 改为 >= 2 使阴影在距离右侧边缘 2 像素以内时隐藏,有效解决了精度问题导致的阴影残留。这与 src/Table.tsx 第 510 行的改动协同工作。

可选说明:注意到 Table.tsx 使用 1 像素阈值而此处使用 2 像素,可能因为此处需要考虑 offsetFixedEndShadow 的额外影响。如果方便的话,可以在注释中说明两个阈值不同的原因,或考虑提取为共享常量:

 const showEndShadow =
   (isFixEnd && fixedEndShadow && scrollWidth - absScroll) -
-    // Same as above
+    // Use threshold of 2 to account for offsetFixedEndShadow and precision issues
     (offsetFixedEndShadow as number) >=
   2;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6a249a2 and b09a58d.

📒 Files selected for processing (2)
  • src/Cell/index.tsx (1 hunks)
  • src/Table.tsx (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: bbb169
Repo: react-component/table PR: 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` 是解决该问题所必须的。
📚 Learning: 2024-11-08T12:53:09.293Z
Learnt from: bbb169
Repo: react-component/table PR: 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` 是解决该问题所必须的。

Applied to files:

  • src/Table.tsx

@codecov
Copy link

codecov bot commented Nov 7, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.09%. Comparing base (6a249a2) to head (2e325da).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1404   +/-   ##
=======================================
  Coverage   96.09%   96.09%           
=======================================
  Files          57       57           
  Lines        3434     3434           
  Branches      632      632           
=======================================
  Hits         3300     3300           
  Misses        129      129           
  Partials        5        5           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@afc163 afc163 merged commit c8d2df1 into react-component:master Nov 7, 2025
7 of 8 checks passed
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.

demo 右侧固定列阴影一直存在

2 participants