diff --git a/src/SelectTrigger.jsx b/src/SelectTrigger.jsx index 66363c74..44bc72d1 100644 --- a/src/SelectTrigger.jsx +++ b/src/SelectTrigger.jsx @@ -171,6 +171,7 @@ const SelectTrigger = React.createClass({ showIcon: props.treeIcon, showLine: props.treeLine, defaultExpandAll: props.treeDefaultExpandAll, + defaultExpandedKeys: props.treeDefaultExpandedKeys, filterTreeNode: this.highlightTreeNode, }; @@ -196,7 +197,7 @@ const SelectTrigger = React.createClass({ } // expand keys - if (!trProps.defaultExpandAll && !props.loadData) { + if (!trProps.defaultExpandAll && !trProps.defaultExpandedKeys && !props.loadData) { trProps.expandedKeys = keys; } trProps.autoExpandParent = true; diff --git a/tests/Select.spec.js b/tests/Select.spec.js index 2da90096..fa617caf 100644 --- a/tests/Select.spec.js +++ b/tests/Select.spec.js @@ -237,4 +237,19 @@ describe('TreeSelect', () => { treeWrapper.find('.rc-tree-select-tree-checkbox').simulate('click'); expect(wrapper.state().value).toEqual([{ value: '0', label: 'label0' }]); }); + + it('expand tree nodes by treeDefaultExpandedKeys', () => { + const wrapper = mount( + + + + + + + + ); + const treeWrapper = mount(wrapper.find('Trigger').node.getComponent()); + const node = treeWrapper.find('.rc-tree-select-tree-node-content-wrapper').at(1); + expect(node.hasClass('rc-tree-select-tree-node-content-wrapper-open')).toBe(true); + }); });