diff --git a/components/table/__tests__/Table.filter.test.js b/components/table/__tests__/Table.filter.test.js index 140959585d..3b1a1bfaa4 100644 --- a/components/table/__tests__/Table.filter.test.js +++ b/components/table/__tests__/Table.filter.test.js @@ -223,6 +223,16 @@ describe('Table.filter', () => { expect(handleChange).toBeCalledWith({}, { name: ['boy'] }, {}); }); + it('should not fire change event on close filterDropdown without changing anything', () => { + const handleChange = jest.fn(); + const wrapper = mount(createTable({ onChange: handleChange })); + const dropdownWrapper = mount(wrapper.find('Trigger').instance().getComponent()); + + dropdownWrapper.find('.clear').simulate('click'); + + expect(handleChange).not.toHaveBeenCalled(); + }); + it('three levels menu', () => { const filters = [ { text: 'Upper', value: 'Upper' }, diff --git a/components/table/filterDropdown.tsx b/components/table/filterDropdown.tsx index ec0a958820..acbac6b2d7 100755 --- a/components/table/filterDropdown.tsx +++ b/components/table/filterDropdown.tsx @@ -108,8 +108,10 @@ export default class FilterMenu extends React.Component, F } confirmFilter() { - if (this.state.selectedKeys !== this.props.selectedKeys) { - this.props.confirmFilter(this.props.column, this.state.selectedKeys); + const { selectedKeys } = this.state; + + if (!shallowequal(selectedKeys, this.props.selectedKeys)) { + this.props.confirmFilter(this.props.column, selectedKeys); } }