mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-11 03:22:59 +08:00
fix(descriptions): correct calculation of last item's span in useRow hook (#52410)
fix(descriptions): correct calculation of last item's span in useRow hook
This commit is contained in:
parent
357dd53f85
commit
88d81e541f
@ -102,6 +102,20 @@ describe('Descriptions', () => {
|
|||||||
expect(container.querySelectorAll('.ant-descriptions-item')[6]).toHaveAttribute('colSpan', '2');
|
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', () => {
|
it('column is number', () => {
|
||||||
const wrapper = render(
|
const wrapper = render(
|
||||||
<Descriptions column={3}>
|
<Descriptions column={3}>
|
||||||
|
@ -53,7 +53,7 @@ function getCalcRows(
|
|||||||
if (count < mergedColumn) {
|
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
|
// 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];
|
const last = rows[rows.length - 1];
|
||||||
last.span = mergedColumn - count + 1;
|
last.span = mergedColumn - (count - (last.span || 1));
|
||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
return rows;
|
return rows;
|
||||||
|
Loading…
Reference in New Issue
Block a user