增加autoSelectWhenFocus参数

This commit is contained in:
yangchch6 2019-08-20 10:41:34 +08:00
parent 101756fa84
commit 10903ed0e4
6 changed files with 39 additions and 20 deletions

View File

@ -575,7 +575,9 @@ var Tree = function (_React$Component) {
this.setState({
focusKey: eventKey
});
// this.onSelect(nextTreeNode);
if (props.autoSelectWhenFocus) {
this.onSelect(nextTreeNode);
}
}
};
@ -628,7 +630,9 @@ var Tree = function (_React$Component) {
this.setState({
focusKey: eventKey
});
// this.onSelect(prevTreeNode);
if (props.autoSelectWhenFocus) {
this.onSelect(prevTreeNode);
}
};
// all keyboard events callbacks run from here at first
@ -1217,7 +1221,8 @@ Tree.propTypes = {
openAnimation: _propTypes2["default"].oneOfType([_propTypes2["default"].string, _propTypes2["default"].object]),
lazyLoad: _propTypes2["default"].bool,
treeData: _propTypes2["default"].array,
renderTreeNodes: _propTypes2["default"].func
renderTreeNodes: _propTypes2["default"].func,
autoSelectWhenFocus: _propTypes2["default"].bool
};
Tree.defaultProps = {
@ -1244,7 +1249,8 @@ Tree.defaultProps = {
onDrop: noop,
onDragEnd: noop,
tabIndexValue: 0,
lazyLoad: false
lazyLoad: false,
autoSelectWhenFocus: false
};
exports["default"] = Tree;

File diff suppressed because one or more lines are too long

26
dist/demo.js vendored

File diff suppressed because one or more lines are too long

2
dist/demo.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -59,6 +59,7 @@ import 'bee-tree/build/Tree.css';
|lazyLoad|是否使用懒加载(适用于大数据场景),[如何使用](http://bee.tinper.org/tinper-bee/bee-tree#%E6%BB%9A%E5%8A%A8%E5%8A%A0%E8%BD%BD%E6%A0%91%E8%8A%82%E7%82%B9)|bool|false
|renderTitle|使用 treeData 渲染树时使用,可通过此函数自定义树节点内容|Function(item)|-
|renderTreeNodes|使用 treeData 渲染树节点时,可使用该函数自定义节点显示内容(非必须)|Function(data)|-
|autoSelectWhenFocus|使用“↑、↓”快捷键切换焦点时,是否自动选中树节点|bool|false
### TreeNode

View File

@ -529,7 +529,9 @@ onExpand(treeNode,keyType) {
this.setState({
focusKey: eventKey
})
// this.onSelect(nextTreeNode);
if(props.autoSelectWhenFocus){
this.onSelect(nextTreeNode);
}
}
}
@ -583,7 +585,9 @@ onExpand(treeNode,keyType) {
this.setState({
focusKey: eventKey
})
// this.onSelect(prevTreeNode);
if(props.autoSelectWhenFocus){
this.onSelect(prevTreeNode);
}
}
// all keyboard events callbacks run from here at first
onKeyDown(e,treeNode) {
@ -1128,7 +1132,8 @@ Tree.propTypes = {
openAnimation: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
lazyLoad: PropTypes.bool,
treeData: PropTypes.array,
renderTreeNodes: PropTypes.func
renderTreeNodes: PropTypes.func,
autoSelectWhenFocus: PropTypes.bool
};
Tree.defaultProps = {
@ -1155,7 +1160,8 @@ Tree.defaultProps = {
onDrop: noop,
onDragEnd: noop,
tabIndexValue:0,
lazyLoad: false
lazyLoad: false,
autoSelectWhenFocus: false
};
export default Tree;