mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-18 11:18:14 +08:00
support undefined remove filter icon (#22833)
This commit is contained in:
parent
3f8dbc500f
commit
9aa61b78e1
@ -57,6 +57,18 @@ describe('Table.filter', () => {
|
|||||||
return wrapper.find('BodyRow').map(row => row.props().record.name);
|
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', () => {
|
it('renders filter correctly', () => {
|
||||||
const wrapper = mount(createTable());
|
const wrapper = mount(createTable());
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ function collectFilterStates<RecordType>(
|
|||||||
|
|
||||||
if ('children' in column) {
|
if ('children' in column) {
|
||||||
filterStates = [...filterStates, ...collectFilterStates(column.children, init, columnPos)];
|
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) {
|
if ('filteredValue' in column) {
|
||||||
// Controlled
|
// Controlled
|
||||||
filterStates.push({
|
filterStates.push({
|
||||||
@ -70,7 +70,7 @@ function injectFilter<RecordType>(
|
|||||||
const columnPos = getColumnPos(index, pos);
|
const columnPos = getColumnPos(index, pos);
|
||||||
const { filterMultiple = true } = column as ColumnType<RecordType>;
|
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 columnKey = getColumnKey(column, columnPos);
|
||||||
const filterState = filterStates.find(({ key }) => columnKey === key);
|
const filterState = filterStates.find(({ key }) => columnKey === key);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user