From 265233c34ff8ca0a7a30c2743ce31e6bd66c4f48 Mon Sep 17 00:00:00 2001 From: QiangGuZi <42662849+QiangGuZi@users.noreply.github.com> Date: Tue, 1 Nov 2022 13:36:24 +0800 Subject: [PATCH] fix(directory-tree): expose scrollTo method. (#6067) Co-authored-by: tan_qiang --- components/tree/DirectoryTree.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/tree/DirectoryTree.tsx b/components/tree/DirectoryTree.tsx index 12704f593..4e1ffa5aa 100644 --- a/components/tree/DirectoryTree.tsx +++ b/components/tree/DirectoryTree.tsx @@ -18,6 +18,7 @@ import { conductExpandParent } from '../vc-tree/util'; import { calcRangeKeys, convertDirectoryKeysToNodes } from './utils/dictUtil'; import useConfigInject from '../_util/hooks/useConfigInject'; import { filterEmpty } from '../_util/props-util'; +import { ScrollTo } from "../vc-tree/interface"; export type ExpandAction = false | 'click' | 'doubleclick' | 'dblclick'; @@ -81,7 +82,11 @@ export default defineComponent({ const cachedSelectedKeys = ref(); const fieldNames = computed(() => fillFieldNames(props.fieldNames)); const treeRef = ref(); + const scrollTo: ScrollTo = scroll => { + treeRef.value?.scrollTo(scroll); + }; expose({ + scrollTo, selectedKeys: computed(() => treeRef.value?.selectedKeys), checkedKeys: computed(() => treeRef.value?.checkedKeys), halfCheckedKeys: computed(() => treeRef.value?.halfCheckedKeys),