fix: Table.Column should correct handle sorter state (#21194)

This commit is contained in:
二货机器人 2020-02-03 16:48:13 +08:00 committed by GitHub
parent 4d26ed83e3
commit b4519407b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 1 deletions

View File

@ -670,4 +670,35 @@ describe('Table.sorter', () => {
expect(wrapper.find('.ant-table-column-sorter-inner')).toHaveLength(0);
});
// https://github.com/ant-design/ant-design/issues/21193
it('table with sugar column', () => {
const wrapper = mount(
<Table>
<Table.Column
title="Chinese Score"
dataIndex="chinese"
sorter={{
compare: (a, b) => a.chinese - b.chinese,
multiple: 3,
}}
/>
<Table.Column
title="Math Score"
dataIndex="math"
sorter={{
compare: (a, b) => a.math - b.math,
multiple: 2,
}}
/>
</Table>,
);
wrapper
.find('th')
.first()
.simulate('click');
expect(wrapper.find('th.ant-table-column-sort')).toHaveLength(1);
});
});

View File

@ -2,7 +2,7 @@
import { ColumnType, ColumnTitle, ColumnTitleProps, Key } from './interface';
export function getColumnKey<RecordType>(column: ColumnType<RecordType>, defaultKey: string): Key {
if ('key' in column && column.key !== undefined) {
if ('key' in column && column.key !== undefined && column.key !== null) {
return column.key;
}
if (column.dataIndex) {