Skip to content
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

fix(descriptions): last item span fill remaining column #52410

Merged
merged 3 commits into from
Jan 17, 2025
Merged
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
14 changes: 14 additions & 0 deletions components/descriptions/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,20 @@ describe('Descriptions', () => {
expect(container.querySelectorAll('.ant-descriptions-item')[6]).toHaveAttribute('colSpan', '2');
});

it('when column=6, last item span should be 5', () => {
const { container } = render(
<Descriptions
column={6}
items={[
{ label: '0', children: '' },
{ label: '1', children: '', span: 2 },
]}
/>,
);
expect(container.querySelectorAll('.ant-descriptions-item')[0]).toHaveAttribute('colSpan', '1');
expect(container.querySelectorAll('.ant-descriptions-item')[1]).toHaveAttribute('colSpan', '5');
});

it('column is number', () => {
const wrapper = render(
<Descriptions column={3}>
Expand Down
2 changes: 1 addition & 1 deletion components/descriptions/hooks/useRow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function getCalcRows(
if (count < mergedColumn) {
// If the span of the last element in the current row is less than the column, then add its span to the remaining columns
const last = rows[rows.length - 1];
last.span = mergedColumn - count + 1;
last.span = mergedColumn - (count - (last.span || 1));
return rows;
}
return rows;
Expand Down
Loading