Skip to content

Conversation

afc163
Copy link
Member

@afc163 afc163 commented Sep 22, 2025

Copy link

vercel bot commented Sep 22, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
table Ready Ready Preview Comment Sep 22, 2025 11:11am

Copy link

coderabbitai bot commented Sep 22, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

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

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.

✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/measurerow-ref

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.

Copy link
Contributor

Summary of Changes

Hello @afc163, 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 addresses and fixes a specific bug within the Ant Design Table component's measurement system. The core issue arose when column headers were complex React elements that included refs, leading to potential rendering or measurement inconsistencies. The solution involves a targeted modification to how these elements are processed, ensuring that ref attributes are neutralized during the measurement phase, thereby preventing conflicts and stabilizing the table's layout behavior.

Highlights

  • Refactored MeasureCell Props: The MeasureCell component's props have been updated to directly accept a title prop of type React.ReactNode, removing the previous dependency on the full column object. This simplifies the component's interface and clarifies its responsibility.
  • Ref Handling in MeasureRow: Introduced logic within MeasureRow to detect if a column's title is a React element with ref attributes. If so, the element is cloned with its ref explicitly set to null before being passed to MeasureCell.
  • Bug Fix for Table Measurement: This change resolves a bug where the Table component's measurement process (MeasureRow) could encounter issues or fail when column titles contained React elements that utilized refs, ensuring robust layout calculations.
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

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 in the MeasureRow component that occurs when a column's title is a React element with a ref. The fix involves cloning the title element and stripping its ref before measurement, which is a sound approach to prevent React warnings. The accompanying refactoring in MeasureCell to accept a title prop instead of the entire column object is a good improvement for component decoupling. I have one suggestion regarding a potential performance optimization in MeasureRow.tsx.

}}
>
{columnsKey.map(columnKey => {
const column = columns.find(col => col.key === columnKey);
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Using Array.prototype.find inside a map results in an O(N*M) time complexity, where N is the length of columnsKey and M is the length of columns. This can lead to performance degradation on tables with a large number of columns.

For better performance, you could create a lookup map from the columns array before iterating. This would reduce the complexity of finding a column to O(1) inside the loop.

You can achieve this by creating a memoized map at the top level of your component, like so:

const columnsMap = React.useMemo(() => {
  const map = new Map<React.Key, (typeof columns)[number]>();
  for (const col of columns) {
    if (col.key) {
      map.set(col.key, col);
    }
  }
  return map;
}, [columns]);

Then, inside your map function, you can retrieve the column efficiently:

const column = columnsMap.get(columnKey);

Copy link

codecov bot commented Sep 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.69%. Comparing base (313b619) to head (a2cf27d).
⚠️ Report is 1 commits behind head on antd-5.x.

Additional details and impacted files
@@            Coverage Diff            @@
##           antd-5.x    #1367   +/-   ##
=========================================
  Coverage     97.69%   97.69%           
=========================================
  Files            77       77           
  Lines          7668     7672    +4     
  Branches       1161     1164    +3     
=========================================
+ Hits           7491     7495    +4     
  Misses          171      171           
  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 f9809b7 into antd-5.x Sep 22, 2025
10 checks passed
@afc163 afc163 deleted the fix/measurerow-ref branch September 22, 2025 11:15
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.

2 participants