Skip to content

Conversation

afc163
Copy link
Member

@afc163 afc163 commented Oct 9, 2025

Reverts #1376

Summary by CodeRabbit

  • 新特性
  • 重构
    • 简化度量标题处理,统一元素与文本标题的渲染表现;无用户可见变更。
  • 杂务
    • 清理冗余内部工具与旧逻辑,减少代码体积与维护成本。

Copy link

vercel bot commented Oct 9, 2025

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

Project Deployment Preview Comments Updated (UTC)
table Ready Ready Preview Comment Oct 9, 2025 11:08am

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 undoes a previous attempt to fix issues related to duplicate unique identifiers in table measure row column headers. The original solution involved a dedicated utility file for filtering props and preparing titles, which has now been removed. The current change simplifies the logic by directly handling React element cloning within the MeasureRow component to manage potential ref conflicts, streamlining the codebase and removing an abstraction that may have introduced other issues.

Highlights

  • Reversion of Previous Fix: This pull request fully reverts a prior change (fix: duplicate unique identifiers in MeasureRow column headers #1376) that aimed to address duplicate unique identifiers within MeasureRow column headers.
  • Removal of Utility File: The src/utils/measureUtil.ts file, which contained helper functions like prepareMeasureTitle, filterMeasureProps, and filterMeasureChildren for handling measure row elements, has been entirely removed.
  • Simplified Title Handling: The MeasureRow component now directly checks if a column title is a valid React element and, if so, clones it to explicitly set its ref prop to null. This replaces the dependency on the removed prepareMeasureTitle utility.
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

coderabbitai bot commented Oct 9, 2025

Walkthrough

在 MeasureRow 中用内联逻辑替代 prepareMeasureTitle;删除 src/utils/measureUtil.ts(包含 filterMeasureProps 与 prepareMeasureTitle)。MeasureRow 现在在运行时判断列标题是否为 React 元素并按需 clone(移除 ref),否则直接使用原值。

Changes

Cohort / File(s) Summary
Measure row title handling
src/Body/MeasureRow.tsx
移除 prepareMeasureTitle 引用;改为:若 rawTitle 为 React 元素则 cloneElement 并将 ref 置为 null,否则直接使用 rawTitle。更新 titleForMeasure 的生成逻辑。
Removed measure utilities
src/utils/measureUtil.ts
整个文件删除;移除导出函数:filterMeasureProps、prepareMeasureTitle;同时删除内部的 filterMeasureChildren。涉及公共 API 删除。

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Table
  participant MeasureRow
  participant React

  Table->>MeasureRow: render(columns)
  loop For each column
    MeasureRow->>MeasureRow: rawTitle = column.title
    alt rawTitle 是 React 元素
      MeasureRow->>React: cloneElement(rawTitle, { ref: null })
      React-->>MeasureRow: titleForMeasure(已移除 ref)
    else 非元素
      MeasureRow->>MeasureRow: titleForMeasure = rawTitle
    end
  end
  MeasureRow-->>Table: 渲染测量行(不再使用 filterMeasureProps/prepareMeasureTitle)
  note over MeasureRow: 已移除 measureUtil 依赖与递归过滤
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

一只码兔跃枝头,
量行无援自出手。
标题若为元素否?
是则轻拂除其钩(ref)。
工具辞别风吹走,
行间清爽更从容。 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed 该标题明确指出此 PR 的主要目的,即撤销先前对 MeasureRow 列标头重复唯一标识符的修复,简洁且准确地反映了更改的核心,因此符合标题要求。
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch revert-1376-fix-duplicate-id-for-measurerow

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

@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 reverts a previous fix that addressed an issue with duplicate unique identifiers in MeasureRow column headers. By reverting this change, the application will once again be susceptible to creating duplicate DOM element IDs when column titles are complex React components. This can lead to invalid HTML and issues with accessibility and testing. I have added a comment highlighting this regression and questioning the rationale behind the revert, as it appears to re-introduce a known bug.

Comment on lines +40 to +42
const titleForMeasure = React.isValidElement<React.RefAttributes<any>>(rawTitle)
? React.cloneElement(rawTitle, { ref: null })
: rawTitle;
Copy link
Contributor

Choose a reason for hiding this comment

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

high

This revert re-introduces an issue where unique identifiers in column titles (like id, data-testid, etc.) can be duplicated in the DOM. The MeasureRow is a hidden element used for measuring, and if it renders a column title that is a React component with such identifiers, it will create duplicate IDs. This is invalid HTML and can cause problems with accessibility and testing frameworks.

The previous implementation that is being removed (prepareMeasureTitle from the now-deleted measureUtil.ts) correctly stripped these problematic props. By reverting to only nullifying the ref, the original bug is being brought back.

If there was a specific problem with the previous fix that prompted this revert, it would be beneficial to document it. Otherwise, it would be best to avoid re-introducing this bug.

Copy link

codecov bot commented Oct 9, 2025

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1377      +/-   ##
==========================================
- Coverage   96.10%   96.09%   -0.01%     
==========================================
  Files          58       57       -1     
  Lines        3492     3434      -58     
  Branches      640      632       -8     
==========================================
- Hits         3356     3300      -56     
+ Misses        131      129       -2     
  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 2bd67c7 into master Oct 9, 2025
11 of 13 checks passed
@afc163 afc163 deleted the revert-1376-fix-duplicate-id-for-measurerow branch October 9, 2025 11:10
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: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c58ee99 and 55866d1.

📒 Files selected for processing (2)
  • src/Body/MeasureRow.tsx (1 hunks)
  • src/utils/measureUtil.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • src/utils/measureUtil.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: test / react component workflow
  • GitHub Check: test / react component workflow

Comment on lines +40 to +42
const titleForMeasure = React.isValidElement<React.RefAttributes<any>>(rawTitle)
? React.cloneElement(rawTitle, { ref: null })
: rawTitle;
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

🧩 Analysis chain

请说明回滚原因并验证不会重新引入原 bug。

此 PR 回滚了修复重复唯一标识符的 #1376。建议:

  1. 在 PR 描述中说明回滚的原因(原修复是否引入了其他问题?)
  2. 验证回滚后不会重新引入原来的重复 ID 问题
  3. 确认当前的内联逻辑能够正确处理所有边缘情况

另外,类型注解 React.RefAttributes<any> 使用了 any,建议改为更具体的类型以提高类型安全性。

运行以下脚本搜索 PR #1376 的相关讨论和测试用例:


🏁 Script executed:

#!/bin/bash
# 查找 PR #1376 的相关信息和测试
gh pr view 1376 --json title,body,comments

# 搜索相关的测试文件
fd -e test.tsx -e test.ts -e spec.tsx -e spec.ts | xargs rg -l "MeasureRow|duplicate.*id" 

Length of output: 22036


澄清回滚原因并验证不再引入重复唯一标识符问题

建议:

  1. 在 PR 描述中说明此次回滚的具体原因(例如 measureUtilDashboardColumnTitle 等自定义组件内部的 id/data-* 属性无法递归清理)并规划后续解决方案。
  2. 确认目前的内联逻辑已涵盖 prepareMeasureTitle 原有的递归过滤能力,并为嵌套组件场景添加单元测试。
  3. React.RefAttributes<any> 替换为更精确的类型(如 JSX.Element 或自定义泛型),提升类型安全。

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.

1 participant