mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 06:03:38 +08:00
fix: Tree filter select all behavior (#34295)
ref https://github.com/ant-design/ant-design/issues/34280
This commit is contained in:
parent
5d51e8b5b4
commit
1df2ecd66e
@ -1964,6 +1964,34 @@ describe('Table.filter', () => {
|
||||
expect(wrapper.find('.ant-tree-checkbox').at(0).hasClass('ant-tree-checkbox-checked')).toBe(
|
||||
true,
|
||||
);
|
||||
expect(wrapper.find('.ant-table-filter-dropdown-checkall .ant-checkbox').hasClass('ant-checkbox-indeterminate')).toBe(true);
|
||||
});
|
||||
|
||||
it('select-all checkbox should change when all items are selected', () => {
|
||||
jest.useFakeTimers();
|
||||
jest.spyOn(console, 'error').mockImplementation(() => undefined);
|
||||
const wrapper = mount(
|
||||
createTable({
|
||||
columns: [
|
||||
{
|
||||
...column,
|
||||
filterMode: 'tree',
|
||||
filters: [
|
||||
{ text: 'Boy', value: 'boy' },
|
||||
{ text: 'Girl', value: 'girl' },
|
||||
],
|
||||
},
|
||||
],
|
||||
}),
|
||||
);
|
||||
wrapper.find('span.ant-dropdown-trigger').simulate('click', nativeEvent);
|
||||
act(() => {
|
||||
jest.runAllTimers();
|
||||
wrapper.update();
|
||||
});
|
||||
wrapper.find('.ant-tree-node-content-wrapper').at(0).simulate('click');
|
||||
wrapper.find('.ant-tree-node-content-wrapper').at(1).simulate('click');
|
||||
expect(wrapper.find('.ant-table-filter-dropdown-checkall .ant-checkbox').hasClass('ant-checkbox-checked')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -326,6 +326,11 @@ function FilterDropdown<RecordType>(props: FilterDropdownProps<RecordType>) {
|
||||
<div className={`${tablePrefixCls}-filter-dropdown-tree`}>
|
||||
{filterMultiple ? (
|
||||
<Checkbox
|
||||
checked={selectedKeys.length === flattenKeys(column.filters).length}
|
||||
indeterminate={
|
||||
selectedKeys.length > 0 &&
|
||||
selectedKeys.length < flattenKeys(column.filters).length
|
||||
}
|
||||
className={`${tablePrefixCls}-filter-dropdown-checkall`}
|
||||
onChange={onCheckAll}
|
||||
>
|
||||
|
Loading…
Reference in New Issue
Block a user