🐛 fix Tree switcherIcon prop not working when showLine

close #18810
This commit is contained in:
MrHeer 2019-09-16 19:08:46 +08:00 committed by 偏右
parent e511e50655
commit 4cca77eab7

View File

@ -194,10 +194,20 @@ export default class Tree extends React.Component<TreeProps, any> {
if (loading) {
return <Icon type="loading" className={`${prefixCls}-switcher-loading-icon`} />;
}
if (showLine) {
if (isLeaf) {
if (isLeaf) {
if (showLine) {
return <Icon type="file" className={`${prefixCls}-switcher-line-icon`} />;
}
return null;
}
const switcherCls = `${prefixCls}-switcher-icon`;
if (switcherIcon) {
const switcherOriginCls = switcherIcon.props.className || '';
return React.cloneElement(switcherIcon, {
className: classNames(switcherOriginCls, switcherCls),
});
}
if (showLine) {
return (
<Icon
type={expanded ? 'minus-square' : 'plus-square'}
@ -206,16 +216,6 @@ export default class Tree extends React.Component<TreeProps, any> {
/>
);
}
const switcherCls = `${prefixCls}-switcher-icon`;
if (isLeaf) {
return null;
}
if (switcherIcon) {
const switcherOriginCls = switcherIcon.props.className || '';
return React.cloneElement(switcherIcon, {
className: classNames(switcherOriginCls, switcherCls),
});
}
return <Icon type="caret-down" className={switcherCls} theme="filled" />;
};