Skip to content
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
6 changes: 3 additions & 3 deletions src/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
scrollYStyle = { overflowY: 'hidden' };
}
scrollTableStyle = {
width: scroll.x === true ? 'auto' : scroll.x,
width: scroll?.x === true ? 'auto' : scroll?.x,
minWidth: '100%',
};
}
Expand Down Expand Up @@ -553,7 +553,7 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
// When scroll.x is max-content, no need to fix table layout
// it's width should stretch out to fit content
if (fixColumn) {
return scroll.x === 'max-content' ? 'auto' : 'fixed';
return scroll?.x === 'max-content' ? 'auto' : 'fixed';
}
if (fixHeader || isSticky || flattenColumns.some(({ ellipsis }) => ellipsis)) {
return 'fixed';
Expand Down Expand Up @@ -844,7 +844,7 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
componentWidth,
fixHeader,
fixColumn,
horizonScroll
horizonScroll,
}),
[componentWidth, fixHeader, fixColumn, horizonScroll],
);
Expand Down
29 changes: 29 additions & 0 deletions tests/ExpandRow.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,35 @@ describe('Table.Expand', () => {
expect(wrapper2.render()).toMatchSnapshot();
});

it('does not crash if scroll is not set', () => {
const columns = [
{ title: 'Name', dataIndex: 'name', key: 'name' },
{ title: 'Age', dataIndex: 'age', key: 'age' },
{ title: 'Gender', dataIndex: 'gender', key: 'gender' },
];
const data = [
{ key: 0, name: 'Lucy', age: 27, gender: 'F' },
{ key: 1, name: 'Jack', age: 28, gender: 'M' },
];
const wrapper = mount(
createTable({
columns,
data,
scroll: {},
expandable: { expandedRowRender, fixed: true },
}),
);
const wrapper2 = mount(
createTable({
columns,
data,
expandable: { expandedRowRender, fixed: true },
}),
);
expect(wrapper.render()).toMatchSnapshot();
expect(wrapper2.render()).toMatchSnapshot();
});

it('expandable fix not when expandIconColumnIndex', () => {
const columns = [
{ title: 'Name', dataIndex: 'name', key: 'name' },
Expand Down
304 changes: 304 additions & 0 deletions tests/__snapshots__/ExpandRow.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,310 @@ exports[`Table.Expand childrenColumnName 1`] = `
</div>
`;

exports[`Table.Expand does not crash if scroll is not set 1`] = `
<div
class="rc-table rc-table-fixed-column rc-table-scroll-horizontal rc-table-has-fix-left"
>
<div
class="rc-table-container"
>
<div
class="rc-table-content"
style="overflow-x: auto; overflow-y: hidden;"
>
<table
style="min-width: 100%; table-layout: fixed;"
>
<colgroup>
<col
class="rc-table-expand-icon-col"
/>
</colgroup>
<thead
class="rc-table-thead"
>
<tr>
<th
class="rc-table-cell rc-table-row-expand-icon-cell rc-table-cell-fix-left rc-table-cell-fix-left-last"
style="position: sticky; left: 0px;"
/>
<th
class="rc-table-cell"
>
Name
</th>
<th
class="rc-table-cell"
>
Age
</th>
<th
class="rc-table-cell"
>
Gender
</th>
</tr>
</thead>
<tbody
class="rc-table-tbody"
>
<tr
aria-hidden="true"
class="rc-table-measure-row"
style="height: 0px; font-size: 0;"
>
<td
style="padding: 0px; border: 0px; height: 0px;"
>
<div
style="height: 0px; overflow: hidden;"
>

</div>
</td>
<td
style="padding: 0px; border: 0px; height: 0px;"
>
<div
style="height: 0px; overflow: hidden;"
>

</div>
</td>
<td
style="padding: 0px; border: 0px; height: 0px;"
>
<div
style="height: 0px; overflow: hidden;"
>

</div>
</td>
<td
style="padding: 0px; border: 0px; height: 0px;"
>
<div
style="height: 0px; overflow: hidden;"
>

</div>
</td>
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="0"
>
<td
class="rc-table-cell rc-table-row-expand-icon-cell rc-table-cell-fix-left rc-table-cell-fix-left-last"
style="position: sticky; left: 0px;"
>
<span
class="rc-table-row-expand-icon rc-table-row-collapsed"
/>
</td>
<td
class="rc-table-cell"
>
Lucy
</td>
<td
class="rc-table-cell"
>
27
</td>
<td
class="rc-table-cell"
>
F
</td>
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="1"
>
<td
class="rc-table-cell rc-table-row-expand-icon-cell rc-table-cell-fix-left rc-table-cell-fix-left-last"
style="position: sticky; left: 0px;"
>
<span
class="rc-table-row-expand-icon rc-table-row-collapsed"
/>
</td>
<td
class="rc-table-cell"
>
Jack
</td>
<td
class="rc-table-cell"
>
28
</td>
<td
class="rc-table-cell"
>
M
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
`;

exports[`Table.Expand does not crash if scroll is not set 2`] = `
<div
class="rc-table rc-table-fixed-column rc-table-scroll-horizontal rc-table-has-fix-left"
>
<div
class="rc-table-container"
>
<div
class="rc-table-content"
style="overflow-x: auto; overflow-y: hidden;"
>
<table
style="min-width: 100%; table-layout: fixed;"
>
<colgroup>
<col
class="rc-table-expand-icon-col"
/>
</colgroup>
<thead
class="rc-table-thead"
>
<tr>
<th
class="rc-table-cell rc-table-row-expand-icon-cell rc-table-cell-fix-left rc-table-cell-fix-left-last"
style="position: sticky; left: 0px;"
/>
<th
class="rc-table-cell"
>
Name
</th>
<th
class="rc-table-cell"
>
Age
</th>
<th
class="rc-table-cell"
>
Gender
</th>
</tr>
</thead>
<tbody
class="rc-table-tbody"
>
<tr
aria-hidden="true"
class="rc-table-measure-row"
style="height: 0px; font-size: 0;"
>
<td
style="padding: 0px; border: 0px; height: 0px;"
>
<div
style="height: 0px; overflow: hidden;"
>

</div>
</td>
<td
style="padding: 0px; border: 0px; height: 0px;"
>
<div
style="height: 0px; overflow: hidden;"
>

</div>
</td>
<td
style="padding: 0px; border: 0px; height: 0px;"
>
<div
style="height: 0px; overflow: hidden;"
>

</div>
</td>
<td
style="padding: 0px; border: 0px; height: 0px;"
>
<div
style="height: 0px; overflow: hidden;"
>

</div>
</td>
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="0"
>
<td
class="rc-table-cell rc-table-row-expand-icon-cell rc-table-cell-fix-left rc-table-cell-fix-left-last"
style="position: sticky; left: 0px;"
>
<span
class="rc-table-row-expand-icon rc-table-row-collapsed"
/>
</td>
<td
class="rc-table-cell"
>
Lucy
</td>
<td
class="rc-table-cell"
>
27
</td>
<td
class="rc-table-cell"
>
F
</td>
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="1"
>
<td
class="rc-table-cell rc-table-row-expand-icon-cell rc-table-cell-fix-left rc-table-cell-fix-left-last"
style="position: sticky; left: 0px;"
>
<span
class="rc-table-row-expand-icon rc-table-row-collapsed"
/>
</td>
<td
class="rc-table-cell"
>
Jack
</td>
<td
class="rc-table-cell"
>
28
</td>
<td
class="rc-table-cell"
>
M
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
`;

exports[`Table.Expand not use nest when children is invalidate 1`] = `
<div
class="rc-table"
Expand Down