mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-28 05:05:48 +08:00
fix: Table.Column should correct handle sorter state (#21194)
This commit is contained in:
parent
4d26ed83e3
commit
b4519407b8
@ -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);
|
||||
});
|
||||
});
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user