-
-
Notifications
You must be signed in to change notification settings - Fork 618
[WIP]get columnHeader's real width #1368
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
11266dc
7c534bc
e2ee887
cb9ce0d
6434e7e
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 | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -35,13 +35,13 @@ const MeasureRow: React.FC<MeasureRowProps> = ({ | |||||||||||||||||||||||||||||||||||||||||
}} | ||||||||||||||||||||||||||||||||||||||||||
> | ||||||||||||||||||||||||||||||||||||||||||
{columnsKey.map(columnKey => { | ||||||||||||||||||||||||||||||||||||||||||
const column = columns.find(col => col.key === columnKey); | ||||||||||||||||||||||||||||||||||||||||||
const columnIndex = columns.findIndex(col => col.key === columnKey); | ||||||||||||||||||||||||||||||||||||||||||
return ( | ||||||||||||||||||||||||||||||||||||||||||
<MeasureCell | ||||||||||||||||||||||||||||||||||||||||||
key={columnKey} | ||||||||||||||||||||||||||||||||||||||||||
columnIndex={columnIndex} | ||||||||||||||||||||||||||||||||||||||||||
columnKey={columnKey} | ||||||||||||||||||||||||||||||||||||||||||
onColumnResize={onColumnResize} | ||||||||||||||||||||||||||||||||||||||||||
title={column?.title} | ||||||||||||||||||||||||||||||||||||||||||
/> | ||||||||||||||||||||||||||||||||||||||||||
Comment on lines
37
to
45
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. findIndex 容易失配(列 key 可能缺失或规则不同),直接使用 map 的 index 作为列序更稳,并下传 prefixCls 当列未显式设置 key 或内部生成规则不同,findIndex 可能返回 -1,导致测量失败。使用遍历索引与表头叶子列顺序一致,更可靠。 - {columnsKey.map(columnKey => {
- const columnIndex = columns.findIndex(col => col.key === columnKey);
- return (
- <MeasureCell
- key={columnKey}
- columnIndex={columnIndex}
- columnKey={columnKey}
- onColumnResize={onColumnResize}
- />
- );
- })}
+ {columnsKey.map((columnKey, columnIndex) => (
+ <MeasureCell
+ key={columnKey}
+ columnIndex={columnIndex}
+ prefixCls={prefixCls}
+ columnKey={columnKey}
+ onColumnResize={onColumnResize}
+ />
+ ))} 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||
})} | ||||||||||||||||||||||||||||||||||||||||||
|
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.
为了让
MeasureCell
能够构建正确的 DOM 选择器,而不是使用硬编码的类名,建议将prefixCls
属性传递给它。这能显著提高MeasureCell
组件的健壮性。