fix: update visible nodes when at root path

This commit is contained in:
EnixCoda 2019-02-21 16:19:06 +08:00
parent 874894261b
commit 1f3378beed
No known key found for this signature in database
GPG key ID: 6825847C88AA329A

View file

@ -248,17 +248,15 @@ const search: MethodCreator<Props, ConnectorState, [string]> = dispatch => {
const delayExpandThreshold = 400
const goTo: MethodCreator<Props, ConnectorState, [string[]]> = dispatch => async currentPath => {
if (currentPath.length) {
await visibleNodesGenerator.search('')
dispatch.set({ searchKey: '', searched: false })
const nodeExpandedTo = visibleNodesGenerator.expandTo(currentPath.join('/'))
if (nodeExpandedTo) {
visibleNodesGenerator.focusNode(nodeExpandedTo)
const { nodes } = visibleNodesGenerator.visibleNodes
tasksAfterRender.push(() => DOMHelper.scrollToNodeElement(nodes.indexOf(nodeExpandedTo)))
dispatch.call(updateVisibleNodes)
}
await visibleNodesGenerator.search('')
dispatch.set({ searchKey: '', searched: false })
const nodeExpandedTo = visibleNodesGenerator.expandTo(currentPath.join('/'))
if (nodeExpandedTo) {
visibleNodesGenerator.focusNode(nodeExpandedTo)
const { nodes } = visibleNodesGenerator.visibleNodes
tasksAfterRender.push(() => DOMHelper.scrollToNodeElement(nodes.indexOf(nodeExpandedTo)))
}
dispatch.call(updateVisibleNodes)
}
function shouldDelayExpand(node: TreeNode) {