mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 02:59:58 +08:00
bug fix : expand all leaf nodes in root level (#47567)
* fix table's scrollbar background color in dark mode
* docs : fix "fille" with "filled"
* expand all leaf nodes in root level
* Add type annotation
* code style format
* [CodeFactor] Apply fixes to commit 116efaf
[ci skip] [skip ci]
* simplify the code and add the corresponding testing module
---------
Co-authored-by: codefactor-io <support@codefactor.io>
This commit is contained in:
parent
7d782ad642
commit
1b696510e5
@ -65,7 +65,7 @@ const DirectoryTree: React.ForwardRefRenderFunction<RcTree, DirectoryTreeProps>
|
||||
keyEntities,
|
||||
);
|
||||
} else {
|
||||
initExpandedKeys = (props.expandedKeys || defaultExpandedKeys)!;
|
||||
initExpandedKeys = props.expandedKeys || defaultExpandedKeys || [];
|
||||
}
|
||||
return initExpandedKeys;
|
||||
};
|
||||
|
@ -123,6 +123,30 @@ describe('Directory Tree', () => {
|
||||
expect(asFragment().firstChild).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('select multi nodes when shift key down', () => {
|
||||
const treeData = [
|
||||
{ title: 'leaf 0-0', key: '0-0-0', isLeaf: true },
|
||||
{ title: 'leaf 0-1', key: '0-0-1', isLeaf: true },
|
||||
{ title: 'leaf 1-0', key: '0-1-0', isLeaf: true },
|
||||
{ title: 'leaf 1-1', key: '0-1-1', isLeaf: true },
|
||||
];
|
||||
const { container } = render(
|
||||
<DirectoryTree multiple defaultExpandAll={false} treeData={treeData} />,
|
||||
);
|
||||
expect(container.querySelectorAll('.ant-tree-node-content-wrapper').length).toBe(4);
|
||||
expect(container.querySelectorAll('.ant-tree-node-selected').length).toBe(0);
|
||||
const leaf0 = container.querySelectorAll('.ant-tree-node-content-wrapper')[0];
|
||||
const leaf1 = container.querySelectorAll('.ant-tree-node-content-wrapper')[1];
|
||||
const leaf2 = container.querySelectorAll('.ant-tree-node-content-wrapper')[2];
|
||||
const leaf3 = container.querySelectorAll('.ant-tree-node-content-wrapper')[3];
|
||||
fireEvent.click(leaf2);
|
||||
fireEvent.click(leaf0, { shiftKey: true });
|
||||
expect(leaf0).toHaveClass('ant-tree-node-selected');
|
||||
expect(leaf1).toHaveClass('ant-tree-node-selected');
|
||||
expect(leaf2).toHaveClass('ant-tree-node-selected');
|
||||
expect(leaf3).not.toHaveClass('ant-tree-node-selected');
|
||||
});
|
||||
|
||||
it('DirectoryTree should expend all when use treeData and defaultExpandAll is true', () => {
|
||||
const treeData = [
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user