Skip to content

Commit

Permalink
feat(tree): scrollto support key match value
Browse files Browse the repository at this point in the history
  • Loading branch information
uyarn committed Sep 19, 2023
1 parent 495ddd0 commit 1f60fc0
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
2 changes: 1 addition & 1 deletion src/tree/Tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ const Tree = forwardRef((props: TreeProps, ref: React.Ref<TreeInstanceFunctions>
return;
}
const data = isVirtual ? visibleData : visibleNodes;
index = data?.findIndex((item) => get(item.data, 'key') === params.key);
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.`);
}
Expand Down
2 changes: 0 additions & 2 deletions src/tree/_example/vscroll.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ export default () => {
{
label: `第${i}段第1个子节点`,
value: `${i}.1`,
key: `${i}.1`,
},
{
label: `第${i}段第2个子节点`,
value: `${i}.2`,
key: `${i}.2`,
},
],
});
Expand Down

0 comments on commit 1f60fc0

Please sign in to comment.