fix: undefined in filterDropdown in Table should not render dropdown filter icon. (#27002)

close #26988
This commit is contained in:
Lim Shang Yi 2020-10-04 21:56:29 +08:00 committed by GitHub
parent 514cc062be
commit fa3c00ce1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -69,6 +69,19 @@ describe('Table.filter', () => {
expect(wrapper.find('.ant-table-filter-column')).toHaveLength(0);
});
// https://github.com/ant-design/ant-design/issues/26988
it('not show filter icon when filter and filterDropdown is undefined', () => {
const noFilterColumn = { ...column, filters: undefined, filterDropdown: 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());

View File

@ -70,7 +70,7 @@ function injectFilter<RecordType>(
const columnPos = getColumnPos(index, pos);
const { filterMultiple = true } = column as ColumnType<RecordType>;
if (column.filters || 'filterDropdown' in column) {
if (column.filters || column.filterDropdown) {
const columnKey = getColumnKey(column, columnPos);
const filterState = filterStates.find(({ key }) => columnKey === key);