fix: Table with controlled filteredValue empty array should not highlight the filtered icon (#24263)

* fix: FilteredValue

* update test case name
This commit is contained in:
二货机器人 2020-05-18 22:03:20 +08:00 committed by GitHub
parent f64558da89
commit 44cfc351cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View File

@ -1104,6 +1104,21 @@ describe('Table.filter', () => {
expect(wrapper.find('.ant-table-filter-trigger').hasClass('active')).toBeTruthy();
});
it('filteredValue with empty array should not active the filtered icon', () => {
const wrapper = mount(
createTable({
columns: [
{
...column,
filteredValue: [],
},
],
}),
);
expect(wrapper.find('.ant-table-filter-trigger').hasClass('active')).toBeFalsy();
});
it('with onFilter', () => {
const onFilter = jest.fn((value, record) => record.key === value);
const columns = [{ dataIndex: 'key', filteredValue: [5], onFilter }];
@ -1132,6 +1147,5 @@ describe('Table.filter', () => {
expect(wrapper.find('tbody tr')).toHaveLength(1);
expect(wrapper.find('tbody tr td').text()).toEqual('Jack');
});
});

View File

@ -83,7 +83,7 @@ function FilterDropdown<RecordType>(props: FilterDropdownProps<RecordType>) {
const filtered: boolean = !!(
filterState &&
(filterState.filteredKeys || filterState.forceFiltered)
(filterState.filteredKeys?.length || filterState.forceFiltered)
);
const triggerVisible = (newVisible: boolean) => {
setVisible(newVisible);