mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-04 04:58:55 +08:00
fix: Table onFilter only should work (#22317)
* adjust table logic * test case
This commit is contained in:
parent
8fa2252903
commit
f4d3dc4306
@ -1213,4 +1213,14 @@ describe('Table.filter', () => {
|
||||
|
||||
expect(wrapper.find('.ant-table-filter-trigger').hasClass('active')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('with onFilter', () => {
|
||||
const onFilter = jest.fn((value, record) => record.key === value);
|
||||
const columns = [{ dataIndex: 'key', filteredValue: [5], onFilter }];
|
||||
const testData = [{ key: 1 }, { key: 3 }, { key: 5 }];
|
||||
const wrapper = mount(<Table columns={columns} dataSource={testData} />);
|
||||
|
||||
expect(onFilter).toHaveBeenCalled();
|
||||
expect(wrapper.find('tbody tr')).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
|
@ -31,7 +31,7 @@ function collectFilterStates<RecordType>(
|
||||
|
||||
if ('children' in column) {
|
||||
filterStates = [...filterStates, ...collectFilterStates(column.children, init, columnPos)];
|
||||
} else if ('filters' in column || 'filterDropdown' in column) {
|
||||
} else if ('filters' in column || 'filterDropdown' in column || 'onFilter' in column) {
|
||||
if ('filteredValue' in column) {
|
||||
// Controlled
|
||||
filterStates.push({
|
||||
|
Loading…
Reference in New Issue
Block a user