mirror of
https://github.com/ant-design/ant-design.git
synced 2025-08-06 16:06:28 +08:00
close #20511
This commit is contained in:
parent
539b4cd968
commit
2ebaa7e7a6
@ -30,4 +30,16 @@ describe('Tree', () => {
|
||||
);
|
||||
expect(wrapper.render()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('switcherIcon in Tree should not render at leaf nodes', () => {
|
||||
const wrapper = mount(
|
||||
<Tree switcherIcon={<i className="switcherIcon" />} defaultExpandAll>
|
||||
<TreeNode icon="icon">
|
||||
<TreeNode id="node1" title="node1" icon="icon" key="0-0-2" />
|
||||
<TreeNode id="node2" title="node2" key="0-0-3" />
|
||||
</TreeNode>
|
||||
</Tree>,
|
||||
);
|
||||
expect(wrapper.find('.switcherIcon').length).toBe(1);
|
||||
});
|
||||
});
|
||||
|
@ -19,16 +19,12 @@ export default function renderSwitcherIcon(
|
||||
return <LoadingOutlined className={`${prefixCls}-switcher-loading-icon`} />;
|
||||
}
|
||||
if (isLeaf) {
|
||||
if (showLine) {
|
||||
return <FileOutlined className={`${prefixCls}-switcher-line-icon`} />;
|
||||
}
|
||||
return null;
|
||||
return showLine ? <FileOutlined className={`${prefixCls}-switcher-line-icon`} /> : null;
|
||||
}
|
||||
const switcherCls = `${prefixCls}-switcher-icon`;
|
||||
if (React.isValidElement(switcherIcon)) {
|
||||
const switcherOriginCls = switcherIcon.props.className || '';
|
||||
return React.cloneElement(switcherIcon, {
|
||||
className: classNames(switcherOriginCls, switcherCls),
|
||||
className: classNames(switcherIcon.props.className || '', switcherCls),
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user