Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(table): fix Table aria-label contains [object Object] #38389

Merged
merged 11 commits into from Nov 5, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -26954,7 +26954,7 @@ exports[`ConfigProvider components Table configProvider 1`] = `
>
<tr>
<th
aria-label="Name sortable"
aria-label="this column's title is Name,this column is sortable"
class="config-table-cell config-table-column-has-sorters"
tabindex="0"
>
Expand Down Expand Up @@ -27260,7 +27260,7 @@ exports[`ConfigProvider components Table configProvider componentDisabled 1`] =
>
<tr>
<th
aria-label="Name sortable"
aria-label="this column's title is Name,this column is sortable"
class="config-table-cell config-table-column-has-sorters"
tabindex="0"
>
Expand Down Expand Up @@ -27568,7 +27568,7 @@ exports[`ConfigProvider components Table configProvider componentSize large 1`]
>
<tr>
<th
aria-label="Name sortable"
aria-label="this column's title is Name,this column is sortable"
class="config-table-cell config-table-column-has-sorters"
tabindex="0"
>
Expand Down Expand Up @@ -27874,7 +27874,7 @@ exports[`ConfigProvider components Table configProvider componentSize middle 1`]
>
<tr>
<th
aria-label="Name sortable"
aria-label="this column's title is Name,this column is sortable"
class="config-table-cell config-table-column-has-sorters"
tabindex="0"
>
Expand Down Expand Up @@ -28180,7 +28180,7 @@ exports[`ConfigProvider components Table configProvider virtual and dropdownMatc
>
<tr>
<th
aria-label="Name sortable"
aria-label="this column's title is Name,this column is sortable"
class="ant-table-cell ant-table-column-has-sorters"
tabindex="0"
>
Expand Down Expand Up @@ -28486,7 +28486,7 @@ exports[`ConfigProvider components Table normal 1`] = `
>
<tr>
<th
aria-label="Name sortable"
aria-label="this column's title is Name,this column is sortable"
class="ant-table-cell ant-table-column-has-sorters"
tabindex="0"
>
Expand Down Expand Up @@ -28792,7 +28792,7 @@ exports[`ConfigProvider components Table prefixCls 1`] = `
>
<tr>
<th
aria-label="Name sortable"
aria-label="this column's title is Name,this column is sortable"
class="prefix-Table-cell prefix-Table-column-has-sorters"
tabindex="0"
>
Expand Down
4 changes: 3 additions & 1 deletion components/table/__tests__/Table.sorter.test.tsx
Expand Up @@ -105,7 +105,9 @@ describe('Table.sorter', () => {

fireEvent.click(container.querySelector('.ant-table-column-sorters')!);
expect(getNameColumn()?.getAttribute('aria-sort')).toEqual(null);
expect(getNameColumn()?.getAttribute('aria-label')).toEqual('Name sortable');
expect(getNameColumn()?.getAttribute('aria-label')).toEqual(
"this column's title is Name,this column is sortable",
);
});

it('sort records', () => {
Expand Down
47 changes: 47 additions & 0 deletions components/table/__tests__/Table.test.tsx
Expand Up @@ -287,6 +287,53 @@ describe('Table', () => {
expect(warnSpy).not.toHaveBeenCalled();
});

// https://github.com/ant-design/ant-design/issues/38371
it('should render title', () => {
const columns = [
{
title: (
<div>
<span>name</span>
<span>Jason</span>
</div>
),
key: 'name',
sorter: true,
},
{
title: (
<div>
<i />
</div>
),
key: 'name',
sorter: true,
},
{
title: () => (
<div>
<span>age</span>
<span>20</span>
</div>
),
key: 'name',
sorter: true,
},
{
title: () => 'color',
key: 'name',
sorter: true,
},
{
title: 'sex',
key: 'name',
sorter: true,
},
];
const { container } = render(<Table columns={columns} />);
expect(container).toMatchSnapshot();
});
kiner-tang marked this conversation as resolved.
Show resolved Hide resolved

it('title should support ReactNode', () => {
const { container } = render(
<Table
Expand Down
Expand Up @@ -6,7 +6,7 @@ exports[`Table.sorter renders sorter icon correctly 1`] = `
>
<tr>
<th
aria-label="Name sortable"
aria-label="this column's title is Name,this column is sortable"
class="ant-table-cell ant-table-column-has-sorters"
tabindex="0"
>
Expand Down