-
-
Notifications
You must be signed in to change notification settings - Fork 618
fix: fix sticky header column width with empty data #1323
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
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Note Other AI code review bot(s) detectedCodeRabbit 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. Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## antd-5.x #1323 +/- ##
============================================
- Coverage 97.74% 97.74% -0.01%
============================================
Files 77 77
Lines 7625 7623 -2
Branches 1155 1154 -1
============================================
- Hits 7453 7451 -2
Misses 166 166
Partials 6 6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Pull Request Overview
This PR fixes an issue with sticky header column widths when the table has empty data. The fix ensures that column widths are properly maintained in sticky headers when there's no data by using the original column group instead of calculated widths.
Key changes:
- Modified
FixedHolder
to conditionally use originalcolGroup
for empty data scenarios - Removed
maxContentScroll
property handling that was causing width calculation issues - Added test cases to verify the fix for various empty data scenarios
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
src/FixedHolder/index.tsx |
Updates column width logic to use original colGroup when no data is present |
src/Table.tsx |
Passes bodyColGroup to FixedHolder components and removes maxContentScroll prop |
docs/examples/stickyHeader.tsx |
Adds test cases for sticky headers with empty data scenarios |
tests/__snapshots__/FixedColumn.spec.tsx.snap |
Updates test snapshots to reflect new column width behavior |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
> | ||
{(!noData || !maxContentScroll || allFlattenColumnsWithWidth) && ( | ||
{/* use original ColGroup if no data, otherwise use calculated column width */} | ||
{noData ? ( |
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.
如果只有 noData 会不会不够,虽然没数据列头不换行了,那还有个场景(列的数据比列头少,也会换行吧?)
我目前的解法是,取 title 的元素,在第一行里 height =0 再渲染一次,撑起宽度
]; | ||
|
||
const columnsWithWidth: ColumnType<RecordType>[] = [ | ||
{ title: 'title1', dataIndex: 'a', key: 'a', width: 100 }, |
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.
使用了 max-content
,这里不应该再加 width 的,这样会忽略掉问题。
ant-design/ant-design#54741