mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-07 17:44:35 +08:00
fix: table onChange event is fired every time when close filterDropdown
Close #11164
This commit is contained in:
parent
e91f67b87c
commit
968371b22a
@ -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' },
|
||||
|
@ -108,8 +108,10 @@ export default class FilterMenu<T> extends React.Component<FilterMenuProps<T>, 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user