Skip to content

Commit

Permalink
fix: Table with controlled filteredValue empty array should not hig…
Browse files Browse the repository at this point in the history
…hlight the filtered icon (#24263)

* fix: FilteredValue

* update test case name
  • Loading branch information
zombieJ committed May 18, 2020
1 parent f64558d commit 44cfc35
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion components/table/__tests__/Table.filter.test.js
Expand Up @@ -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 }];
Expand Down Expand Up @@ -1132,6 +1147,5 @@ describe('Table.filter', () => {

expect(wrapper.find('tbody tr')).toHaveLength(1);
expect(wrapper.find('tbody tr td').text()).toEqual('Jack');

});
});
2 changes: 1 addition & 1 deletion components/table/hooks/useFilter/FilterDropdown.tsx
Expand Up @@ -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);
Expand Down

0 comments on commit 44cfc35

Please sign in to comment.