diff --git a/components/table/__tests__/Table.filter.test.js b/components/table/__tests__/Table.filter.test.js
index 7f93412439..00a66669b3 100644
--- a/components/table/__tests__/Table.filter.test.js
+++ b/components/table/__tests__/Table.filter.test.js
@@ -2052,4 +2052,71 @@ describe('Table.filter', () => {
wrapper.find('.ant-table-filter-dropdown-btns .ant-btn-primary').simulate('click');
expect(renderedNames(wrapper)).toEqual(['Jack']);
});
+
+ it('clearFilters should support params', () => {
+ const filterConfig = [
+ ['Jack', 'NoParams', {}, ['Jack'], true],
+ ['Lucy', 'Confirm', { confirm: true }, ['Jack', 'Lucy', 'Tom', 'Jerry'], true],
+ ['Tom', 'Close', { closeDropdown: true }, ['Tom'], false],
+ [
+ 'Jerry',
+ 'Params',
+ { closeDropdown: true, confirm: true },
+ ['Jack', 'Lucy', 'Tom', 'Jerry'],
+ false,
+ ],
+ ];
+ const filter = ({ prefixCls, setSelectedKeys, confirm, clearFilters }) => (
+
+ {filterConfig.map(([text, id, param]) => (
+ <>
+ {
+ setSelectedKeys([text]);
+ confirm();
+ }}
+ id={`set${id}`}
+ >
+ setSelectedKeys
+
+ clearFilters(param)} id={`reset${id}`}>
+ Reset
+
+ >
+ ))}
+
+ );
+
+ const wrapper = mount(
+ createTable({
+ columns: [
+ {
+ ...column,
+ filterDropdown: filter,
+ },
+ ],
+ }),
+ );
+
+ function getFilterMenu() {
+ return wrapper.find('FilterDropdown');
+ }
+
+ // check if renderer well
+ wrapper.find('span.ant-dropdown-trigger').simulate('click', nativeEvent);
+ expect(wrapper.find('#customFilter')).toMatchSnapshot();
+ expect(getFilterMenu().props().filterState.filteredKeys).toBeFalsy();
+
+ filterConfig.forEach(([text, id, , res1, res2]) => {
+ wrapper.find(`#set${id}`).simulate('click');
+ wrapper.update();
+ expect(renderedNames(wrapper)).toEqual([text]);
+
+ wrapper.find('span.ant-dropdown-trigger').simulate('click', nativeEvent);
+ wrapper.find(`#reset${id}`).simulate('click');
+ wrapper.update();
+ expect(renderedNames(wrapper)).toEqual(res1);
+ expect(wrapper.find('Dropdown').first().props().visible).toBe(res2);
+ });
+ });
});
diff --git a/components/table/__tests__/__snapshots__/Table.filter.test.js.snap b/components/table/__tests__/__snapshots__/Table.filter.test.js.snap
index c01f5d3957..2b3bac0583 100644
--- a/components/table/__tests__/__snapshots__/Table.filter.test.js.snap
+++ b/components/table/__tests__/__snapshots__/Table.filter.test.js.snap
@@ -1,5 +1,61 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
+exports[`Table.filter clearFilters should support params 1`] = `
+
+
+ setSelectedKeys
+
+
+ Reset
+
+
+ setSelectedKeys
+
+
+ Reset
+
+
+ setSelectedKeys
+
+
+ Reset
+
+
+ setSelectedKeys
+
+
+ Reset
+
+
+`;
+
exports[`Table.filter override custom filter correctly 1`] = `
children);
}
@@ -203,7 +208,15 @@ function FilterDropdown
(props: FilterDropdownProps) {
internalTriggerFilter(getFilteredKeysSync());
};
- const onReset = () => {
+ const onReset = (
+ { confirm, closeDropdown }: FilterRestProps = { confirm: false, closeDropdown: false },
+ ) => {
+ if (confirm) {
+ internalTriggerFilter([]);
+ }
+ if (closeDropdown) {
+ triggerVisible(false);
+ }
setSearchValue('');
setFilteredKeysSync([]);
};
@@ -367,7 +380,12 @@ function FilterDropdown(props: FilterDropdownProps) {
<>
{getFilterComponent()}
-