Skip to content

Commit

Permalink
fix: index and key of ScrollToElementParams should be optional (#2626)
Browse files Browse the repository at this point in the history
  • Loading branch information
uyarn authored Nov 30, 2023
1 parent e78daa3 commit 18ebde9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export type InfinityScroll = TScroll;

export interface ScrollToElementParams {
/** 跳转元素下标 */
index: number;
index?: number;
/** 跳转元素距离顶部的距离 */
top?: number;
/** 单个元素高度非固定场景下,即 isFixedRowHeight = false。延迟设置元素位置,一般用于依赖不同高度异步渲染等场景,单位:毫秒 */
Expand All @@ -124,5 +124,5 @@ export interface ScrollToElementParams {
}

export interface ComponentScrollToElementParams extends ScrollToElementParams {
key: string | number;
key?: string | number;
}
3 changes: 1 addition & 2 deletions src/tree/_example/vscroll.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export default () => {
newOptions.push({
label: `第${i}段`,
value: i,
key: i,
children: [
{
label: `第${i}段第1个子节点`,
Expand All @@ -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'];
Expand Down

0 comments on commit 18ebde9

Please sign in to comment.