fix: 懒加载无法打开问题修复
This commit is contained in:
parent
2151c4c836
commit
35e9ff65e8
|
@ -34539,6 +34539,7 @@
|
|||
};
|
||||
|
||||
Tree.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
|
||||
var flatTreeDataDone = false; //已经更新过flatTree
|
||||
var startIndex = this.startIndex,
|
||||
endIndex = this.endIndex,
|
||||
props = this.props,
|
||||
|
@ -34571,6 +34572,7 @@
|
|||
st.flatTreeData = flatTreeData;
|
||||
var newTreeList = flatTreeData.slice(startIndex, endIndex);
|
||||
this.handleTreeListChange(newTreeList, startIndex, endIndex);
|
||||
flatTreeDataDone = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34594,10 +34596,12 @@
|
|||
this.dataChange = true;
|
||||
//treeData更新时,需要重新处理一次数据
|
||||
if (nextProps.lazyLoad) {
|
||||
var _flatTreeData = this.deepTraversal(nextProps.treeData);
|
||||
st.flatTreeData = _flatTreeData;
|
||||
var _newTreeList = _flatTreeData.slice(startIndex, endIndex);
|
||||
this.handleTreeListChange(_newTreeList, startIndex, endIndex);
|
||||
if (!flatTreeDataDone) {
|
||||
var _flatTreeData = this.deepTraversal(nextProps.treeData);
|
||||
st.flatTreeData = _flatTreeData;
|
||||
var _newTreeList = _flatTreeData.slice(startIndex, endIndex);
|
||||
this.handleTreeListChange(_newTreeList, startIndex, endIndex);
|
||||
}
|
||||
} else {
|
||||
st.treeData = nextProps.treeData;
|
||||
}
|
||||
|
@ -35164,8 +35168,8 @@
|
|||
|
||||
var tabIndexKey = selectedKeys[0];
|
||||
var isExist = false;
|
||||
var treeNode = children.length && children[0];
|
||||
var eventKey = treeNode.props.eventKey || treeNode.key;
|
||||
var treeNode = children && children.length && children[0];
|
||||
var eventKey = treeNode && treeNode.props.eventKey || treeNode.key;
|
||||
if (this.selectKeyDomExist && tabIndexKey || !tabIndexKey) {
|
||||
isExist = true;
|
||||
var queryInfo = 'a[pos="' + this.selectKeyDomPos + '"]';
|
||||
|
|
File diff suppressed because one or more lines are too long
17
src/Tree.js
17
src/Tree.js
|
@ -98,6 +98,7 @@ class Tree extends React.Component {
|
|||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
let flatTreeDataDone = false;//已经更新过flatTree
|
||||
const {startIndex,endIndex,props,state} = this;
|
||||
const {prevProps} = state;
|
||||
const expandedKeys = this.getDefaultExpandedKeys(nextProps, true);
|
||||
|
@ -126,6 +127,7 @@ class Tree extends React.Component {
|
|||
st.flatTreeData = flatTreeData;
|
||||
let newTreeList = flatTreeData.slice(startIndex,endIndex);
|
||||
this.handleTreeListChange(newTreeList, startIndex, endIndex);
|
||||
flatTreeDataDone=true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -149,10 +151,13 @@ class Tree extends React.Component {
|
|||
this.dataChange = true;
|
||||
//treeData更新时,需要重新处理一次数据
|
||||
if(nextProps.lazyLoad) {
|
||||
let flatTreeData = this.deepTraversal(nextProps.treeData);
|
||||
st.flatTreeData = flatTreeData;
|
||||
let newTreeList = flatTreeData.slice(startIndex,endIndex);
|
||||
this.handleTreeListChange(newTreeList, startIndex, endIndex);
|
||||
if(!flatTreeDataDone){
|
||||
let flatTreeData = this.deepTraversal(nextProps.treeData);
|
||||
st.flatTreeData = flatTreeData;
|
||||
let newTreeList = flatTreeData.slice(startIndex,endIndex);
|
||||
this.handleTreeListChange(newTreeList, startIndex, endIndex);
|
||||
}
|
||||
|
||||
} else {
|
||||
st.treeData = nextProps.treeData;
|
||||
}
|
||||
|
@ -721,8 +726,8 @@ onExpand(treeNode,keyType) {
|
|||
const {selectedKeys=[]} = this.state;
|
||||
let tabIndexKey = selectedKeys[0]
|
||||
let isExist = false;
|
||||
const treeNode = children.length && children[0];
|
||||
let eventKey = treeNode.props.eventKey || treeNode.key;
|
||||
const treeNode = children&&children.length && children[0];
|
||||
let eventKey = treeNode&&treeNode.props.eventKey || treeNode.key;
|
||||
if((this.selectKeyDomExist && tabIndexKey) || !tabIndexKey){
|
||||
isExist = true;
|
||||
const queryInfo = `a[pos="${this.selectKeyDomPos}"]`;
|
||||
|
|
Loading…
Reference in New Issue