mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 19:19:57 +08:00
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:
parent
f64558da89
commit
44cfc351cb
@ -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');
|
||||
|
||||
});
|
||||
});
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user