二货机器人
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
14 additions and
2 deletions
-
components/table/__tests__/Table.filter.test.js
-
components/table/hooks/useFilter/index.tsx
|
|
@ -57,6 +57,18 @@ describe('Table.filter', () => { |
|
|
|
return wrapper.find('BodyRow').map(row => row.props().record.name); |
|
|
|
} |
|
|
|
|
|
|
|
it('not show filter icon when undefined', () => { |
|
|
|
const noFilterColumn = { ...column, filters: undefined }; |
|
|
|
delete noFilterColumn.onFilter; |
|
|
|
const wrapper = mount( |
|
|
|
createTable({ |
|
|
|
columns: [noFilterColumn], |
|
|
|
}), |
|
|
|
); |
|
|
|
|
|
|
|
expect(wrapper.find('.ant-table-filter-column')).toHaveLength(0); |
|
|
|
}); |
|
|
|
|
|
|
|
it('renders filter correctly', () => { |
|
|
|
const wrapper = mount(createTable()); |
|
|
|
|
|
|
|
|
|
@ -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 || 'onFilter' in column) { |
|
|
|
} else if (column.filters || 'filterDropdown' in column || 'onFilter' in column) { |
|
|
|
if ('filteredValue' in column) { |
|
|
|
// Controlled
|
|
|
|
filterStates.push({ |
|
|
@ -70,7 +70,7 @@ function injectFilter<RecordType>( |
|
|
|
const columnPos = getColumnPos(index, pos); |
|
|
|
const { filterMultiple = true } = column as ColumnType<RecordType>; |
|
|
|
|
|
|
|
if ('filters' in column || 'filterDropdown' in column) { |
|
|
|
if (column.filters || 'filterDropdown' in column) { |
|
|
|
const columnKey = getColumnKey(column, columnPos); |
|
|
|
const filterState = filterStates.find(({ key }) => columnKey === key); |
|
|
|
|
|
|
|