fix(动态获取parentEle):
This commit is contained in:
parent
fcc27437e1
commit
8b0bea5ed7
|
@ -457,7 +457,8 @@ var Tree = function (_React$Component) {
|
||||||
//查询的下一个节点不为空的话,则选中
|
//查询的下一个节点不为空的话,则选中
|
||||||
if (nextTreeNode) {
|
if (nextTreeNode) {
|
||||||
var queryInfo = 'a[pos="' + nextPos + '"]';
|
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();
|
focusEle && focusEle.focus();
|
||||||
this.onSelect(nextTreeNode);
|
this.onSelect(nextTreeNode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,7 +198,7 @@ var TreeNode = function (_React$Component) {
|
||||||
|
|
||||||
TreeNode.prototype.onKeyDown = function onKeyDown(e) {
|
TreeNode.prototype.onKeyDown = function onKeyDown(e) {
|
||||||
this.props.root.onKeyDown(e, this);
|
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();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,6 +12,7 @@ exports.handleCheckState = handleCheckState;
|
||||||
exports.getCheck = getCheck;
|
exports.getCheck = getCheck;
|
||||||
exports.getStrictlyValue = getStrictlyValue;
|
exports.getStrictlyValue = getStrictlyValue;
|
||||||
exports.arraysEqual = arraysEqual;
|
exports.arraysEqual = arraysEqual;
|
||||||
|
exports.closest = closest;
|
||||||
|
|
||||||
var _react = require('react');
|
var _react = require('react');
|
||||||
|
|
||||||
|
@ -324,4 +325,17 @@ function arraysEqual(a, b) {
|
||||||
if (a[i] !== b[i]) return false;
|
if (a[i] !== b[i]) return false;
|
||||||
}
|
}
|
||||||
return true;
|
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",
|
"name": "bee-tree",
|
||||||
"version": "1.1.9",
|
"version": "1.1.10",
|
||||||
"description": "Tree ui component for react",
|
"description": "Tree ui component for react",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react",
|
"react",
|
||||||
|
|
Loading…
Reference in New Issue