Skip to content

Commit 63f6e17

Browse files
committed
fix: TreeNode props should not miss by children node
1 parent 50479b4 commit 63f6e17

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/hooks/useTreeData.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,13 @@ function formatTreeData(
6363

6464
function dig(dataNodes: DataNode[]) {
6565
return (dataNodes || []).map(node => {
66-
const { key, disableCheckbox, disabled } = node;
66+
const { key, children, ...restProps } = node;
6767

6868
const value = node[fieldValue];
6969
const mergedValue = fieldValue in node ? value : key;
7070

7171
const dataNode: InternalDataEntity = {
72-
disableCheckbox,
73-
disabled,
72+
...restProps,
7473
key: key !== null && key !== undefined ? key : mergedValue,
7574
value: mergedValue,
7675
title: getLabelProp(node),

tests/Select.tree.spec.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ describe('TreeSelect.tree', () => {
8383
const spy = jest.spyOn(console, 'error').mockImplementation(() => {});
8484
mount(
8585
<TreeSelect
86-
treeData={[{ title: 'little', value: 'ttt' }, { title: 'bamboo', value: 'ttt' }]}
86+
treeData={[
87+
{ title: 'little', value: 'ttt' },
88+
{ title: 'bamboo', value: 'ttt' },
89+
]}
8790
/>,
8891
);
8992
expect(spy).toHaveBeenCalledWith('Warning: Same `value` exist in the tree: ttt');
@@ -125,4 +128,14 @@ describe('TreeSelect.tree', () => {
125128
});
126129
});
127130
});
131+
132+
it('Node icon', () => {
133+
const wrapper = mount(
134+
<TreeSelect open>
135+
<SelectNode value="little" title="Little" icon={<span className="bamboo-light" />} />
136+
</TreeSelect>,
137+
);
138+
139+
expect(wrapper.exists('.bamboo-light')).toBeTruthy();
140+
});
128141
});

0 commit comments

Comments
 (0)