Browse Source

🐛 Fix sort order of columns in render

array value of columns

close #19398
pull/19442/head
afc163 5 years ago
committed by 偏右
parent
commit
99d8f07607
  1. 5
      components/table/Table.tsx
  2. 2
      components/table/__tests__/Table.sorter.test.js

5
components/table/Table.tsx

@ -69,9 +69,14 @@ function isSameColumn<T>(a: ColumnProps<T> | null, b: ColumnProps<T> | null) {
return (
a === b ||
shallowEqual(a, b, (value: any, other: any) => {
// https://github.com/ant-design/ant-design/issues/12737
if (typeof value === 'function' && typeof other === 'function') {
return value === other || value.toString() === other.toString();
}
// https://github.com/ant-design/ant-design/issues/19398
if (Array.isArray(value) && Array.isArray(other)) {
return value === other || shallowEqual(value, other);
}
})
);
}

2
components/table/__tests__/Table.sorter.test.js

@ -354,6 +354,7 @@ describe('Table.sorter', () => {
});
// https://github.com/ant-design/ant-design/issues/12737
// https://github.com/ant-design/ant-design/issues/19398
it('should toggle sort state when columns with non primitive properties are put in render', () => {
const testData = [
{ key: 0, name: 'Jack', age: 11 },
@ -377,6 +378,7 @@ describe('Table.sorter', () => {
dataIndex: 'name',
sorter: true,
render: text => text,
array: ['1', '2', 3],
},
];
const { pagination } = this.state;

Loading…
Cancel
Save