mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-12 12:23:08 +08:00
fix: The emptyText field of the table (#49599)
* fix: The emptyText field of the table when emptyText is null * test: update test case(#49599)
This commit is contained in:
parent
ff7fea18f3
commit
cc54bef826
@ -547,9 +547,10 @@ const InternalTable = <RecordType extends AnyObject = AnyObject>(
|
|||||||
|
|
||||||
const mergedStyle: React.CSSProperties = { ...table?.style, ...style };
|
const mergedStyle: React.CSSProperties = { ...table?.style, ...style };
|
||||||
|
|
||||||
const emptyText = locale?.emptyText || renderEmpty?.('Table') || (
|
const emptyText =
|
||||||
<DefaultRenderEmpty componentName="Table" />
|
typeof locale?.emptyText !== 'undefined'
|
||||||
);
|
? locale.emptyText
|
||||||
|
: renderEmpty?.('Table') || <DefaultRenderEmpty componentName="Table" />;
|
||||||
|
|
||||||
// ========================== Render ==========================
|
// ========================== Render ==========================
|
||||||
const TableComponent = virtual ? RcVirtualTable : RcTable;
|
const TableComponent = virtual ? RcVirtualTable : RcTable;
|
||||||
|
@ -147,6 +147,104 @@ exports[`Table renders empty table 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`Table renders empty table when emptyText is null 1`] = `
|
||||||
|
<div
|
||||||
|
class="ant-table-wrapper"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-spin-nested-loading"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-spin-container"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-table ant-table-empty"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-table-container"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-table-content"
|
||||||
|
>
|
||||||
|
<table
|
||||||
|
style="table-layout: auto;"
|
||||||
|
>
|
||||||
|
<colgroup />
|
||||||
|
<thead
|
||||||
|
class="ant-table-thead"
|
||||||
|
>
|
||||||
|
<tr>
|
||||||
|
<th
|
||||||
|
class="ant-table-cell"
|
||||||
|
scope="col"
|
||||||
|
>
|
||||||
|
Column 1
|
||||||
|
</th>
|
||||||
|
<th
|
||||||
|
class="ant-table-cell"
|
||||||
|
scope="col"
|
||||||
|
>
|
||||||
|
Column 2
|
||||||
|
</th>
|
||||||
|
<th
|
||||||
|
class="ant-table-cell"
|
||||||
|
scope="col"
|
||||||
|
>
|
||||||
|
Column 3
|
||||||
|
</th>
|
||||||
|
<th
|
||||||
|
class="ant-table-cell"
|
||||||
|
scope="col"
|
||||||
|
>
|
||||||
|
Column 4
|
||||||
|
</th>
|
||||||
|
<th
|
||||||
|
class="ant-table-cell"
|
||||||
|
scope="col"
|
||||||
|
>
|
||||||
|
Column 5
|
||||||
|
</th>
|
||||||
|
<th
|
||||||
|
class="ant-table-cell"
|
||||||
|
scope="col"
|
||||||
|
>
|
||||||
|
Column 6
|
||||||
|
</th>
|
||||||
|
<th
|
||||||
|
class="ant-table-cell"
|
||||||
|
scope="col"
|
||||||
|
>
|
||||||
|
Column 7
|
||||||
|
</th>
|
||||||
|
<th
|
||||||
|
class="ant-table-cell"
|
||||||
|
scope="col"
|
||||||
|
>
|
||||||
|
Column 8
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody
|
||||||
|
class="ant-table-tbody"
|
||||||
|
>
|
||||||
|
<tr
|
||||||
|
class="ant-table-placeholder"
|
||||||
|
>
|
||||||
|
<td
|
||||||
|
class="ant-table-cell"
|
||||||
|
colspan="8"
|
||||||
|
/>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`Table renders empty table with custom emptyText 1`] = `
|
exports[`Table renders empty table with custom emptyText 1`] = `
|
||||||
<div
|
<div
|
||||||
class="ant-table-wrapper"
|
class="ant-table-wrapper"
|
||||||
|
@ -89,6 +89,18 @@ describe('Table', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('renders empty table when emptyText is null', () => {
|
||||||
|
const { container, asFragment } = render(
|
||||||
|
<Table dataSource={[]} columns={columns} pagination={false} locale={{ emptyText: null }} />,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(container.querySelector('.ant-table-placeholder>.ant-table-cell')?.hasChildNodes()).toBe(
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(asFragment().firstChild).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
it('renders empty table with custom emptyText', () => {
|
it('renders empty table with custom emptyText', () => {
|
||||||
const { asFragment } = render(
|
const { asFragment } = render(
|
||||||
<Table
|
<Table
|
||||||
|
Loading…
Reference in New Issue
Block a user