mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 02:59:58 +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 emptyText = locale?.emptyText || renderEmpty?.('Table') || (
|
||||
<DefaultRenderEmpty componentName="Table" />
|
||||
);
|
||||
const emptyText =
|
||||
typeof locale?.emptyText !== 'undefined'
|
||||
? locale.emptyText
|
||||
: renderEmpty?.('Table') || <DefaultRenderEmpty componentName="Table" />;
|
||||
|
||||
// ========================== Render ==========================
|
||||
const TableComponent = virtual ? RcVirtualTable : RcTable;
|
||||
|
@ -147,6 +147,104 @@ exports[`Table renders empty table 1`] = `
|
||||
</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`] = `
|
||||
<div
|
||||
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', () => {
|
||||
const { asFragment } = render(
|
||||
<Table
|
||||
|
Loading…
Reference in New Issue
Block a user