Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/examples/stickyHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ const columns3: ColumnType<RecordType>[] = [
dataIndex: 'age',
key: '7',
},
{ title: 'Column 8', dataIndex: 'address', key: '8' },
{ title: 'Column 8', dataIndex: 'address', width: 200, key: '8' },
{ title: 'Column 9', dataIndex: 'name', key: '9' },
{ title: 'Column 10', dataIndex: 'address', key: '10' },
{ title: 'Column 11', dataIndex: 'address', key: '11' },
Expand Down
2 changes: 1 addition & 1 deletion src/Body/MeasureCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function MeasureCell({ columnKey, onColumnResize, column }: Measu
style={{ paddingTop: 0, paddingBottom: 0, borderTop: 0, borderBottom: 0, height: 0 }}
>
<div style={{ height: 0, overflow: 'hidden', fontWeight: 'bold' }}>
{column?.title || '\xa0'}
{('width' in column ? '' : column?.title) || '\xa0'}
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The column prop is optional and can be undefined. Using the in operator on an undefined value will cause a TypeError at runtime. You should add a null check for column before attempting to access its properties or use the in operator.

Suggested change
{('width' in column ? '' : column?.title) || '\xa0'}
{(column && 'width' in column ? '' : column?.title) || '\xa0'}

Copy link
Member

Choose a reason for hiding this comment

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

这样修好像没效果。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

就是如果传了 width,就不渲染 title 了,还用空占位

Copy link
Member

Choose a reason for hiding this comment

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

没效果,还是 width: auto 的问题,去掉就好了。之前 scroll={{ x: true }} 时默认设置的就是 width: auto,现在可以考虑去掉了。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

也可能吧,我调试的时候,宽度一直不生效,还以为确实有问题,所以才改的。其实是列太多,导致 width 200 本来就会被挤掉的吧

</div>
</td>
</ResizeObserver>
Expand Down