fix: Table expanded logic (#22832)

* update rc-table deps

* fix style mapping

* snapshot
This commit is contained in:
二货机器人 2020-04-01 20:57:35 +08:00 committed by GitHub
parent c38324e863
commit f2a3ef5926
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 141 additions and 49 deletions

View File

@ -429,6 +429,7 @@ describe('Table.rowSelection', () => {
const wrapper = render(
createTable({
rowSelection: { fixed: true },
scroll: { x: 903 },
}),
);
@ -444,6 +445,7 @@ describe('Table.rowSelection', () => {
},
},
rowSelection: { fixed: true },
scroll: { x: 903 },
}),
);
@ -461,6 +463,7 @@ describe('Table.rowSelection', () => {
fixed: 'left',
},
],
scroll: { x: 903 },
}),
);

View File

@ -11,16 +11,17 @@ exports[`Table.rowSelection fix expand on th left when selection column fixed on
class="ant-spin-container"
>
<div
class="ant-table ant-table-has-fix-left"
class="ant-table ant-table-fixed-column ant-table-scroll-horizontal ant-table-has-fix-left"
>
<div
class="ant-table-container"
>
<div
class="ant-table-content"
style="overflow-x:scroll;overflow-y:hidden"
>
<table
style="table-layout:fixed"
style="width:903px;min-width:100%;table-layout:fixed"
>
<colgroup>
<col
@ -72,6 +73,21 @@ exports[`Table.rowSelection fix expand on th left when selection column fixed on
<tbody
class="ant-table-tbody"
>
<tr
aria-hidden="true"
class="ant-table-measure-row"
style="height:0"
>
<td
style="padding:0;border:0;height:0"
/>
<td
style="padding:0;border:0;height:0"
/>
<td
style="padding:0;border:0;height:0"
/>
</tr>
<tr
class="ant-table-row ant-table-row-level-0"
data-row-key="0"
@ -329,16 +345,17 @@ exports[`Table.rowSelection fix selection column on the left 1`] = `
class="ant-spin-container"
>
<div
class="ant-table ant-table-has-fix-left"
class="ant-table ant-table-fixed-column ant-table-scroll-horizontal ant-table-has-fix-left"
>
<div
class="ant-table-container"
>
<div
class="ant-table-content"
style="overflow-x:scroll;overflow-y:hidden"
>
<table
style="table-layout:fixed"
style="width:903px;min-width:100%;table-layout:fixed"
>
<colgroup>
<col
@ -383,6 +400,18 @@ exports[`Table.rowSelection fix selection column on the left 1`] = `
<tbody
class="ant-table-tbody"
>
<tr
aria-hidden="true"
class="ant-table-measure-row"
style="height:0"
>
<td
style="padding:0;border:0;height:0"
/>
<td
style="padding:0;border:0;height:0"
/>
</tr>
<tr
class="ant-table-row ant-table-row-level-0"
data-row-key="0"
@ -600,16 +629,17 @@ exports[`Table.rowSelection fix selection column on the left when any other colu
class="ant-spin-container"
>
<div
class="ant-table ant-table-has-fix-left"
class="ant-table ant-table-fixed-column ant-table-scroll-horizontal ant-table-has-fix-left"
>
<div
class="ant-table-container"
>
<div
class="ant-table-content"
style="overflow-x:scroll;overflow-y:hidden"
>
<table
style="table-layout:fixed"
style="width:903px;min-width:100%;table-layout:fixed"
>
<colgroup>
<col
@ -655,6 +685,18 @@ exports[`Table.rowSelection fix selection column on the left when any other colu
<tbody
class="ant-table-tbody"
>
<tr
aria-hidden="true"
class="ant-table-measure-row"
style="height:0"
>
<td
style="padding:0;border:0;height:0"
/>
<td
style="padding:0;border:0;height:0"
/>
</tr>
<tr
class="ant-table-row ant-table-row-level-0"
data-row-key="0"

View File

@ -4903,7 +4903,7 @@ exports[`renders ./components/table/demo/fixed-columns.md correctly 1`] = `
class="ant-spin-container"
>
<div
class="ant-table ant-table-fixed-column ant-table-has-fix-left ant-table-has-fix-right"
class="ant-table ant-table-fixed-column ant-table-scroll-horizontal ant-table-has-fix-left ant-table-has-fix-right"
>
<div
class="ant-table-container"
@ -5267,7 +5267,7 @@ exports[`renders ./components/table/demo/fixed-columns-header.md correctly 1`] =
class="ant-spin-container"
>
<div
class="ant-table ant-table-fixed-header ant-table-fixed-column ant-table-has-fix-left ant-table-has-fix-right"
class="ant-table ant-table-fixed-header ant-table-fixed-column ant-table-scroll-horizontal ant-table-has-fix-left ant-table-has-fix-right"
>
<div
class="ant-table-container"
@ -7556,7 +7556,7 @@ exports[`renders ./components/table/demo/grouping-columns.md correctly 1`] = `
class="ant-spin-container"
>
<div
class="ant-table ant-table-middle ant-table-bordered ant-table-fixed-header ant-table-fixed-column ant-table-has-fix-left ant-table-has-fix-right"
class="ant-table ant-table-middle ant-table-bordered ant-table-fixed-header ant-table-fixed-column ant-table-scroll-horizontal ant-table-has-fix-left ant-table-has-fix-right"
>
<div
class="ant-table-container"
@ -13886,7 +13886,7 @@ exports[`renders ./components/table/demo/virtual-list.md correctly 1`] = `
class="ant-spin-container"
>
<div
class="ant-table ant-table-fixed-header ant-table-fixed-column"
class="ant-table ant-table-fixed-header ant-table-scroll-horizontal"
>
<div
class="ant-table-container"

View File

@ -240,16 +240,17 @@ exports[`Table renders empty table with fixed columns 1`] = `
class="ant-spin-container"
>
<div
class="ant-table ant-table-has-fix-left ant-table-has-fix-right"
class="ant-table ant-table-fixed-column ant-table-scroll-horizontal ant-table-has-fix-left ant-table-has-fix-right"
>
<div
class="ant-table-container"
>
<div
class="ant-table-content"
style="overflow-x:scroll;overflow-y:hidden"
>
<table
style="table-layout:fixed"
style="width:1px;min-width:100%;table-layout:fixed"
>
<colgroup>
<col
@ -337,6 +338,45 @@ exports[`Table renders empty table with fixed columns 1`] = `
<tbody
class="ant-table-tbody"
>
<tr
aria-hidden="true"
class="ant-table-measure-row"
style="height:0"
>
<td
style="padding:0;border:0;height:0"
/>
<td
style="padding:0;border:0;height:0"
/>
<td
style="padding:0;border:0;height:0"
/>
<td
style="padding:0;border:0;height:0"
/>
<td
style="padding:0;border:0;height:0"
/>
<td
style="padding:0;border:0;height:0"
/>
<td
style="padding:0;border:0;height:0"
/>
<td
style="padding:0;border:0;height:0"
/>
<td
style="padding:0;border:0;height:0"
/>
<td
style="padding:0;border:0;height:0"
/>
<td
style="padding:0;border:0;height:0"
/>
</tr>
<tr
class="ant-table-placeholder"
>
@ -345,50 +385,55 @@ exports[`Table renders empty table with fixed columns 1`] = `
colspan="11"
>
<div
class="ant-empty ant-empty-normal"
class="ant-table-expanded-row-fixed"
style="width:0;position:sticky;left:0;overflow:hidden"
>
<div
class="ant-empty-image"
class="ant-empty ant-empty-normal"
>
<svg
class="ant-empty-img-simple"
height="41"
viewBox="0 0 64 41"
width="64"
xmlns="http://www.w3.org/2000/svg"
<div
class="ant-empty-image"
>
<g
fill="none"
fill-rule="evenodd"
transform="translate(0 1)"
<svg
class="ant-empty-img-simple"
height="41"
viewBox="0 0 64 41"
width="64"
xmlns="http://www.w3.org/2000/svg"
>
<ellipse
class="ant-empty-img-simple-ellipse"
cx="32"
cy="33"
rx="32"
ry="7"
/>
<g
class="ant-empty-img-simple-g"
fill-rule="nonzero"
fill="none"
fill-rule="evenodd"
transform="translate(0 1)"
>
<path
d="M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"
/>
<path
class="ant-empty-img-simple-path"
d="M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z"
<ellipse
class="ant-empty-img-simple-ellipse"
cx="32"
cy="33"
rx="32"
ry="7"
/>
<g
class="ant-empty-img-simple-g"
fill-rule="nonzero"
>
<path
d="M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"
/>
<path
class="ant-empty-img-simple-path"
d="M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z"
/>
</g>
</g>
</g>
</svg>
</svg>
</div>
<p
class="ant-empty-description"
>
No Data
</p>
</div>
<p
class="ant-empty-description"
>
No Data
</p>
</div>
</td>
</tr>

View File

@ -51,7 +51,9 @@ describe('Table', () => {
});
it('renders empty table with fixed columns', () => {
const wrapper = render(<Table dataSource={[]} columns={columnsFixed} pagination={false} />);
const wrapper = render(
<Table dataSource={[]} columns={columnsFixed} pagination={false} scroll={{ x: 1 }} />,
);
expect(wrapper).toMatchSnapshot();
});

View File

@ -53,7 +53,7 @@
}
}
&.@{table-prefix-cls}-fixed-column {
&.@{table-prefix-cls}-scroll-horizontal {
tr.@{table-prefix-cls}-expanded-row,
tr.@{table-prefix-cls}-placeholder {
> td {

View File

@ -127,7 +127,7 @@
"rc-slider": "~9.2.3",
"rc-steps": "~3.5.0",
"rc-switch": "~1.9.0",
"rc-table": "~7.3.0",
"rc-table": "~7.4.2",
"rc-tabs": "~10.1.1",
"rc-tooltip": "~4.0.2",
"rc-tree": "~3.1.0",