Skip to content

Commit

Permalink
fix(Tree): fix scrollto behavior (#3235)
Browse files Browse the repository at this point in the history
  • Loading branch information
uyarn authored Nov 28, 2024
1 parent b5227cb commit 30cc17d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/tree/Tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,15 @@ const Tree = forwardRef<TreeInstanceFunctions<TreeOptionData>, TreeProps>((origi
log.error('Tree', 'scrollToElement: one of `index` or `key` must exist.');
return;
}
const data = isVirtual ? visibleData : visibleNodes;
const data = visibleNodes;
index = data?.findIndex((item) => [get(item.data, 'key'), get(item.data, 'value')].includes(params.key));
if (index < 0) {
log.error('Tree', `${params.key} does not exist in data, check \`key\` or \`data\` please.`);
}
}
scrollToElement({ ...params, index });
},
[scrollToElement, isVirtual, visibleData, visibleNodes],
[scrollToElement, visibleNodes],
);
/** 对外暴露的公共方法 * */
useImperativeHandle<unknown, TreeInstanceFunctions>(
Expand Down

0 comments on commit 30cc17d

Please sign in to comment.