fix(动态获取parentEle):
This commit is contained in:
parent
fcc27437e1
commit
8b0bea5ed7
|
@ -457,7 +457,8 @@ var Tree = function (_React$Component) {
|
|||
//查询的下一个节点不为空的话,则选中
|
||||
if (nextTreeNode) {
|
||||
var queryInfo = 'a[pos="' + nextPos + '"]';
|
||||
var focusEle = e.target.parentElement.parentElement.parentElement.parentElement.querySelector(queryInfo);
|
||||
var parentEle = (0, _util.closest)(e.target, ".u-tree");
|
||||
var focusEle = parentEle ? parentEle.querySelector(queryInfo) : null;
|
||||
focusEle && focusEle.focus();
|
||||
this.onSelect(nextTreeNode);
|
||||
}
|
||||
|
|
|
@ -198,7 +198,7 @@ var TreeNode = function (_React$Component) {
|
|||
|
||||
TreeNode.prototype.onKeyDown = function onKeyDown(e) {
|
||||
this.props.root.onKeyDown(e, this);
|
||||
if (e.keyCode !== _tinperBeeCore.KeyCode.TAB) {
|
||||
if (e.keyCode == _tinperBeeCore.KeyCode.SPACE || e.keyCode == _tinperBeeCore.KeyCode.DOWN || e.keyCode == _tinperBeeCore.KeyCode.LEFT || e.keyCode == _tinperBeeCore.KeyCode.RIGHT || e.keyCode == _tinperBeeCore.KeyCode.UP) {
|
||||
e.preventDefault();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -12,6 +12,7 @@ exports.handleCheckState = handleCheckState;
|
|||
exports.getCheck = getCheck;
|
||||
exports.getStrictlyValue = getStrictlyValue;
|
||||
exports.arraysEqual = arraysEqual;
|
||||
exports.closest = closest;
|
||||
|
||||
var _react = require('react');
|
||||
|
||||
|
@ -325,3 +326,16 @@ function arraysEqual(a, b) {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function closest(el, selector) {
|
||||
var matchesSelector = el.matches || el.webkitMatchesSelector || el.mozMatchesSelector || el.msMatchesSelector;
|
||||
|
||||
while (el) {
|
||||
if (matchesSelector.call(el, selector)) {
|
||||
return el;
|
||||
} else {
|
||||
el = el.parentElement;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "bee-tree",
|
||||
"version": "1.1.9",
|
||||
"version": "1.1.10",
|
||||
"description": "Tree ui component for react",
|
||||
"keywords": [
|
||||
"react",
|
||||
|
|
Loading…
Reference in New Issue