-
-
Notifications
You must be signed in to change notification settings - Fork 618
Revert "fix: duplicate unique identifiers in MeasureRow column headers" #1377
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ import isVisible from '@rc-component/util/lib/Dom/isVisible'; | |
import { useContext } from '@rc-component/context'; | ||
import TableContext from '../context/TableContext'; | ||
import type { ColumnType } from '../interface'; | ||
import { prepareMeasureTitle } from '../utils/measureUtil'; | ||
|
||
export interface MeasureRowProps { | ||
prefixCls: string; | ||
|
@@ -38,8 +37,9 @@ const MeasureRow: React.FC<MeasureRowProps> = ({ | |
{columnsKey.map(columnKey => { | ||
const column = columns.find(col => col.key === columnKey); | ||
const rawTitle = column?.title; | ||
const titleForMeasure = prepareMeasureTitle(rawTitle); | ||
|
||
const titleForMeasure = React.isValidElement<React.RefAttributes<any>>(rawTitle) | ||
? React.cloneElement(rawTitle, { ref: null }) | ||
: rawTitle; | ||
Comment on lines
+40
to
+42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major 🧩 Analysis chain请说明回滚原因并验证不会重新引入原 bug。 此 PR 回滚了修复重复唯一标识符的 #1376。建议:
另外,类型注解 运行以下脚本搜索 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 澄清回滚原因并验证不再引入重复唯一标识符问题 建议:
|
||
return ( | ||
<MeasureCell | ||
key={columnKey} | ||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This revert re-introduces an issue where unique identifiers in column titles (like
id
,data-testid
, etc.) can be duplicated in the DOM. TheMeasureRow
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-deletedmeasureUtil.ts
) correctly stripped these problematic props. By reverting to only nullifying theref
, 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.