diff --git a/components/tree/Tree.tsx b/components/tree/Tree.tsx index 1247f3628d..47cc6e616a 100644 --- a/components/tree/Tree.tsx +++ b/components/tree/Tree.tsx @@ -188,34 +188,30 @@ export default class Tree extends React.Component { renderSwitcherIcon = ( prefixCls: string, switcherIcon: React.ReactElement | undefined, - { isLeaf, expanded, loading, icon }: AntTreeNodeProps, + { isLeaf, expanded, loading }: AntTreeNodeProps, ) => { const { showLine } = this.props; if (loading) { return ; } - if (isLeaf) { - if (showLine) { - return icon || ; - } - return null; - } const switcherCls = `${prefixCls}-switcher-icon`; if (switcherIcon) { return React.cloneElement(switcherIcon, { className: classNames(switcherIcon.props.className || '', switcherCls), }); } - if (showLine) { - return icon || ( - - ); + if (isLeaf) { + return showLine ? : null; } - return ; + return showLine ? ( + + ) : ( + + ); }; setTreeRef = (node: any) => { @@ -228,7 +224,6 @@ export default class Tree extends React.Component { prefixCls: customizePrefixCls, className, showIcon, - showLine, switcherIcon, blockNode, children, @@ -239,9 +234,6 @@ export default class Tree extends React.Component { + > + + + + + > + + + + @@ -2087,13 +2127,13 @@ exports[`renders ./components/tree/demo/switcher-icon.md correctly 1`] = ` class="ant-tree-switcher ant-tree-switcher-noop" > @@ -2125,13 +2165,13 @@ exports[`renders ./components/tree/demo/switcher-icon.md correctly 1`] = ` class="ant-tree-switcher ant-tree-switcher-noop" > diff --git a/components/tree/__tests__/__snapshots__/index.test.js.snap b/components/tree/__tests__/__snapshots__/index.test.js.snap index 84ca6ddf98..f13b6b52b0 100644 --- a/components/tree/__tests__/__snapshots__/index.test.js.snap +++ b/components/tree/__tests__/__snapshots__/index.test.js.snap @@ -1,8 +1,8 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Tree icon of TreeNode should put inside line when showLine is true 1`] = ` +exports[`Tree icon and switcherIcon of Tree with showLine should render correctly 1`] = `
    @@ -13,12 +13,84 @@ exports[`Tree icon of TreeNode should put inside line when showLine is true 1`] - icon + switcherIcon + + icon + + + --- + + + +
  • + + switcherIcon + + + + + --- + + +
  • +
  • + + + + + + + diff --git a/components/tree/__tests__/index.test.js b/components/tree/__tests__/index.test.js index 8a80731b0d..5b0b067bed 100644 --- a/components/tree/__tests__/index.test.js +++ b/components/tree/__tests__/index.test.js @@ -5,12 +5,26 @@ import Tree from '../index'; const { TreeNode } = Tree; describe('Tree', () => { - it('icon of TreeNode should put inside line when showLine is true', () => { + it('icon and switcherIcon of Tree with showLine should render correctly', () => { const wrapper = mount( - - - - + + + + + + + + + + + + + + + + + + , ); diff --git a/components/tree/demo/line.md b/components/tree/demo/line.md index d9300939df..8fa3f9370c 100644 --- a/components/tree/demo/line.md +++ b/components/tree/demo/line.md @@ -37,7 +37,7 @@ class Demo extends React.Component { - } title="leaf" key="0-0-2-1" /> + } title="leaf" key="0-0-2-1" />