Skip to content

Commit 8cbf2b5

Browse files
committed
fix: n-tree scrollTo
1 parent 38e9172 commit 8cbf2b5

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/views/snapshot/WindowCard.vue

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,8 @@ watch([() => focusNode.value, () => focusTime.value], async () => {
3535
lastClickId = Number.NaN;
3636
return;
3737
}
38-
// NTree 被 virtualScroll 包裹后, treeRef.value?.scrollTo 无效, 使用 scrollIntoView
39-
const item = document.querySelector<HTMLElement>(
40-
`[data-node-id="${key}"]`,
41-
);
42-
if (!item) return;
4338
selectedKeys.value = [key];
44-
item.scrollIntoView({ behavior: 'smooth', block: 'center' });
39+
treeRef.value?.scrollTo({ key, behavior: 'smooth', debounce: true });
4540
}
4641
});
4742
let parent = focusNode.value.parent;
@@ -219,13 +214,12 @@ const gkdVersionName = computed(() => {
219214
/>
220215
</div>
221216
<div h-1px mt-4px bg="#efeff5" />
222-
223-
<NScrollbar xScrollable class="flex-1">
217+
<div flex-1 min-h-0>
224218
<NTree
225219
ref="treeRef"
226220
v-model:expandedKeys="expandedKeys"
227221
v-model:selectedKeys="selectedKeys"
228-
class="mb-24px mr-24px"
222+
class="h-full"
229223
virtualScroll
230224
showLine
231225
blockLine
@@ -235,6 +229,6 @@ const gkdVersionName = computed(() => {
235229
:nodeProps="(treeNodeProps as any)"
236230
:renderLabel="(renderLabel as any)"
237231
/>
238-
</NScrollbar>
232+
</div>
239233
</div>
240234
</template>

0 commit comments

Comments
 (0)