Skip to content

fix: header blank when using sticky or scroll.y #1267

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

Merged
merged 2 commits into from
May 9, 2025

Conversation

linxianxi
Copy link
Contributor

@linxianxi linxianxi commented May 9, 2025

fix ant-design/ant-design#49099

Summary by CodeRabbit

  • 优化
    • 改进了表格列宽和滚动条尺寸的同步更新时机,提升了渲染的流畅性和准确性。
    • 优化了列宽调整时的可见性判断逻辑,减少了不必要的更新,提升了性能。

Copy link

vercel bot commented May 9, 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 May 9, 2025 9:20am

Copy link

coderabbitai bot commented May 9, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (2)
  • tests/__snapshots__/FixedColumn.spec.tsx.snap is excluded by !**/*.snap
  • tests/__snapshots__/Table.spec.jsx.snap is excluded by !**/*.snap

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

本次更改主要涉及表格组件的列宽度测量与调整逻辑。主要调整包括:将部分副作用钩子从 useEffect 替换为 useLayoutEffect,以同步处理 DOM 变化;增加了对行元素可见性的判断以避免不必要的列宽更新;简化了列宽状态管理逻辑,并移除了部分可见性检查。

Changes

文件/分组 变更摘要
src/Body/MeasureCell.tsx useEffect 替换为自定义的 useLayoutEffect,同步触发列宽回调。
src/Body/MeasureRow.tsx <tr> 元素添加 ref,回调中新增可见性判断,仅在可见时处理列宽变更。
src/Table.tsx 移除 isVisible 检查,使用 useState 替换 useLayoutState 管理列宽,副作用钩子改为 useLayoutEffect

Sequence Diagram(s)

sequenceDiagram
    participant 用户
    participant Table
    participant MeasureRow
    participant MeasureCell

    用户->>Table: 渲染表格
    Table->>MeasureRow: 渲染测量行
    MeasureRow->>MeasureCell: 渲染测量单元格
    MeasureCell->>MeasureCell: useLayoutEffect 检查并回调 onColumnResize
    MeasureRow->>MeasureRow: 检查可见性后处理 onBatchResize
    MeasureRow->>Table: 通知列宽变化
    Table->>Table: 更新列宽状态
Loading

Suggested reviewers

  • zombieJ
  • MadCcc

Poem

🐰
一行一列巧安排,
钩子同步细节来。
可见判断添保障,
状态简化更明白。
代码跃动春风里,
表格焕新展风采!


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

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

Copy link

codecov bot commented May 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.03%. Comparing base (8078217) to head (8d2dd19).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1267   +/-   ##
=======================================
  Coverage   98.03%   98.03%           
=======================================
  Files          76       76           
  Lines        7425     7427    +2     
  Branches     1146     1143    -3     
=======================================
+ Hits         7279     7281    +2     
  Misses        140      140           
  Partials        6        6           

☔ 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 b98bb3e into react-component:master May 9, 2025
9 checks passed
@afc163
Copy link
Member

afc163 commented May 9, 2025

这里也提交一个 PR:https://github.com/react-component/table/tree/antd-5.x

@linxianxi
Copy link
Contributor Author

这里也提交一个 PR:https://github.com/react-component/table/tree/antd-5.x

这里貌似已经落后好几个 commit 了?

@linxianxi
Copy link
Contributor Author

这里也提交一个 PR:https://github.com/react-component/table/tree/antd-5.x

#1268

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.

Head table title columns blink when use sticky and sorter with useEffect react 18 to set columns
2 participants