diff --git a/components/tree/Tree.tsx b/components/tree/Tree.tsx index 47cc6e616aeb..0bf44c0b43c5 100644 --- a/components/tree/Tree.tsx +++ b/components/tree/Tree.tsx @@ -194,15 +194,15 @@ export default class Tree extends React.Component { if (loading) { return ; } + if (isLeaf) { + return showLine ? : null; + } const switcherCls = `${prefixCls}-switcher-icon`; if (switcherIcon) { return React.cloneElement(switcherIcon, { className: classNames(switcherIcon.props.className || '', switcherCls), }); } - if (isLeaf) { - return showLine ? : null; - } return showLine ? ( - - - - + /> - - - - + /> @@ -2287,13 +2247,13 @@ exports[`renders ./components/tree/demo/switcher-icon.md correctly 1`] = ` class="ant-tree-switcher ant-tree-switcher-noop" > @@ -2325,13 +2285,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__/index.test.js b/components/tree/__tests__/index.test.js index 5b0b067bed3f..7c1822152b6a 100644 --- a/components/tree/__tests__/index.test.js +++ b/components/tree/__tests__/index.test.js @@ -30,4 +30,16 @@ describe('Tree', () => { ); expect(wrapper.render()).toMatchSnapshot(); }); + + it('switcherIcon in Tree should not render at leaf nodes', () => { + const wrapper = mount( + } defaultExpandAll> + + + + + , + ); + expect(wrapper.find('.switcherIcon').length).toBe(1); + }); });