diff --git a/components/table/__tests__/Table.sorter.test.js b/components/table/__tests__/Table.sorter.test.js index 46d2d10f0d..d7cdc93f44 100644 --- a/components/table/__tests__/Table.sorter.test.js +++ b/components/table/__tests__/Table.sorter.test.js @@ -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( + + a.chinese - b.chinese, + multiple: 3, + }} + /> + a.math - b.math, + multiple: 2, + }} + /> +
, + ); + + wrapper + .find('th') + .first() + .simulate('click'); + + expect(wrapper.find('th.ant-table-column-sort')).toHaveLength(1); + }); }); diff --git a/components/table/util.ts b/components/table/util.ts index caaaa2f233..03285adc37 100644 --- a/components/table/util.ts +++ b/components/table/util.ts @@ -2,7 +2,7 @@ import { ColumnType, ColumnTitle, ColumnTitleProps, Key } from './interface'; export function getColumnKey(column: ColumnType, 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) {