mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-11 19:42:54 +08:00
fix: Table childColumnName should support checkStrictly (#28568)
This commit is contained in:
parent
6c63a742aa
commit
076f5f1f00
@ -1057,6 +1057,37 @@ describe('Table.rowSelection', () => {
|
||||
expect(getIndeterminateSelection(wrapper)).toEqual([]);
|
||||
expect(onChange.mock.calls[2][0]).toEqual(['Jerry Tom Tom']);
|
||||
});
|
||||
|
||||
it('should support `childrenColumnName`', () => {
|
||||
const onChange = jest.fn();
|
||||
|
||||
const table = createTable({
|
||||
dataSource: [
|
||||
{
|
||||
key: 0,
|
||||
name: 'Jack',
|
||||
childList: [
|
||||
{ key: 1, name: 'Light' },
|
||||
{ key: 2, name: 'Bamboo' },
|
||||
],
|
||||
},
|
||||
],
|
||||
expandable: {
|
||||
childrenColumnName: 'childList',
|
||||
defaultExpandAllRows: true,
|
||||
},
|
||||
rowSelection: {
|
||||
checkStrictly: false,
|
||||
onChange,
|
||||
},
|
||||
});
|
||||
const wrapper = mount(table);
|
||||
const checkboxes = wrapper.find('input');
|
||||
expect(checkboxes).toHaveLength(1 + 3);
|
||||
|
||||
checkboxes.at(1).simulate('change', { target: { checked: true } });
|
||||
expect(getSelections(wrapper)).toEqual([0, 1, 2]);
|
||||
});
|
||||
});
|
||||
it('warns when set `indeterminate` using `rowSelection.getCheckboxProps` is not allowed with tree structured data.', () => {
|
||||
resetWarned();
|
||||
|
@ -117,8 +117,11 @@ export default function useSelection<RecordType>(
|
||||
() =>
|
||||
checkStrictly
|
||||
? { keyEntities: null }
|
||||
: convertDataToEntities((data as unknown) as DataNode[], undefined, getRowKey as any),
|
||||
[data, getRowKey, checkStrictly],
|
||||
: convertDataToEntities((data as unknown) as DataNode[], {
|
||||
externalGetKey: getRowKey as any,
|
||||
childrenPropName: childrenColumnName,
|
||||
}),
|
||||
[data, getRowKey, checkStrictly, childrenColumnName],
|
||||
);
|
||||
|
||||
// Get flatten data
|
||||
|
@ -143,7 +143,7 @@
|
||||
"rc-tabs": "~11.7.0",
|
||||
"rc-textarea": "~0.3.0",
|
||||
"rc-tooltip": "~5.0.0",
|
||||
"rc-tree": "~4.0.0",
|
||||
"rc-tree": "~4.1.0",
|
||||
"rc-tree-select": "~4.2.0",
|
||||
"rc-upload": "~3.3.4",
|
||||
"rc-util": "^5.1.0",
|
||||
|
Loading…
Reference in New Issue
Block a user