From 18ebde9534db00db88114323798106fc68b5bca1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?w=C5=AB=20y=C4=81ng?= Date: Thu, 30 Nov 2023 12:37:48 +0800 Subject: [PATCH] fix: index and key of ScrollToElementParams should be optional (#2626) --- src/common.ts | 4 ++-- src/tree/_example/vscroll.jsx | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/common.ts b/src/common.ts index 1adbe36e8a..4a18766dfe 100644 --- a/src/common.ts +++ b/src/common.ts @@ -115,7 +115,7 @@ export type InfinityScroll = TScroll; export interface ScrollToElementParams { /** 跳转元素下标 */ - index: number; + index?: number; /** 跳转元素距离顶部的距离 */ top?: number; /** 单个元素高度非固定场景下,即 isFixedRowHeight = false。延迟设置元素位置,一般用于依赖不同高度异步渲染等场景,单位:毫秒 */ @@ -124,5 +124,5 @@ export interface ScrollToElementParams { } export interface ComponentScrollToElementParams extends ScrollToElementParams { - key: string | number; + key?: string | number; } diff --git a/src/tree/_example/vscroll.jsx b/src/tree/_example/vscroll.jsx index 280a7564d7..9bfc2d8a06 100644 --- a/src/tree/_example/vscroll.jsx +++ b/src/tree/_example/vscroll.jsx @@ -13,7 +13,6 @@ export default () => { newOptions.push({ label: `第${i}段`, value: i, - key: i, children: [ { label: `第${i}段第1个子节点`, @@ -30,7 +29,7 @@ export default () => { }, []); const handleScroll = () => { - treeRef.current.scrollTo({ index: '10', behavior: 'smooth' }); + treeRef.current.scrollTo({ key: '10.1', behavior: 'smooth' }); }; const defaultChecked = ['1.2', '2.2'];