From d2a99cd69d697d3c07877bbd5032b8067ee6159d Mon Sep 17 00:00:00 2001 From: wanghaoo Date: Tue, 25 Dec 2018 18:05:20 +0800 Subject: [PATCH] feat: --- build/Tree.js | 7 +++---- build/TreeNode.js | 6 +++++- package.json | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/build/Tree.js b/build/Tree.js index 7a011c5..b5fd679 100644 --- a/build/Tree.js +++ b/build/Tree.js @@ -513,8 +513,7 @@ var Tree = function (_React$Component) { Tree.prototype.onKeyDown = function onKeyDown(e, treeNode) { - // event.preventDefault() - // console.log('-----'+e.keyCode); + var props = this.props; var currentPos = treeNode.props.pos; var currentIndex = currentPos.substr(currentPos.lastIndexOf('-') + 1); @@ -523,13 +522,13 @@ var Tree = function (_React$Component) { this.goDown(currentPos, currentIndex, e, treeNode); } else if (e.keyCode == _tinperBeeCore.KeyCode.UP) { this.goUp(currentPos, currentIndex, e, treeNode); - } else if (e.keyCode == _tinperBeeCore.KeyCode.LEFT) { + } else if (e.keyCode == _tinperBeeCore.KeyCode.LEFT && !treeNode.props.isLeaf) { // 收起树节点 this.onExpand(treeNode, 'left'); } else if (e.keyCode == _tinperBeeCore.KeyCode.RIGHT && !treeNode.props.isLeaf) { // 展开树节点 this.onExpand(treeNode, 'right'); - } else if (e.keyCode == _tinperBeeCore.KeyCode.SPACE && props.checkable && !treeNode.props.isLeaf) { + } else if (e.keyCode == _tinperBeeCore.KeyCode.SPACE && props.checkable) { // 如果是多选tree则进行选中或者反选该节点 this.onCheck(treeNode); } diff --git a/build/TreeNode.js b/build/TreeNode.js index 9545334..40af979 100644 --- a/build/TreeNode.js +++ b/build/TreeNode.js @@ -30,6 +30,8 @@ var _propTypes = require('prop-types'); var _propTypes2 = _interopRequireDefault(_propTypes); +var _tinperBeeCore = require('tinper-bee-core'); + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; } @@ -196,7 +198,9 @@ var TreeNode = function (_React$Component) { TreeNode.prototype.onKeyDown = function onKeyDown(e) { this.props.root.onKeyDown(e, this); - // e.preventDefault(); + if (e.keyCode !== _tinperBeeCore.KeyCode.TAB) { + e.preventDefault(); + } }; TreeNode.prototype.renderSwitcher = function renderSwitcher(props, expandedState) { diff --git a/package.json b/package.json index f17b297..1817f4c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bee-tree", - "version": "1.1.8", + "version": "1.1.9", "description": "Tree ui component for react", "keywords": [ "react",