From 95015b633e7d63e6e7ef5f9397bdfd676e05af1b Mon Sep 17 00:00:00 2001 From: Melloware Date: Sat, 8 Oct 2022 08:40:18 -0400 Subject: [PATCH] Fix #2987: Datascroller do not reset first on lazy (#3442) --- components/lib/datascroller/DataScroller.js | 5 ++++- components/lib/datascroller/datascroller.d.ts | 18 +++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/components/lib/datascroller/DataScroller.js b/components/lib/datascroller/DataScroller.js index 38784cc791..f7f07ac771 100644 --- a/components/lib/datascroller/DataScroller.js +++ b/components/lib/datascroller/DataScroller.js @@ -120,7 +120,10 @@ export const DataScroller = React.memo( if (props.value) { value.current = props.value; - first.current = 0; + if (!props.lazy) { + first.current = 0; + } + dataToRender.current = []; handleDataChange(); } diff --git a/components/lib/datascroller/datascroller.d.ts b/components/lib/datascroller/datascroller.d.ts index 7a6ff19868..48e8f61059 100644 --- a/components/lib/datascroller/datascroller.d.ts +++ b/components/lib/datascroller/datascroller.d.ts @@ -8,19 +8,19 @@ interface DataScrollerLazyLoadParams { } export interface DataScrollerProps extends Omit, HTMLDivElement>, 'ref'> { - value?: any[]; - rows?: number; - inline?: boolean; - scrollHeight?: string; - loader?: boolean; buffer?: number; - header?: React.ReactNode; + children?: React.ReactNode; + emptyMessage?: DataScrollerEmptyMessageType; footer?: React.ReactNode; + header?: React.ReactNode; + inline?: boolean; lazy?: boolean; - emptyMessage?: DataScrollerEmptyMessageType; - onLazyLoad?(e: DataScrollerLazyLoadParams): void; + loader?: boolean; + rows?: number; + scrollHeight?: string; + value?: any[]; itemTemplate?(item: any): React.ReactNode; - children?: React.ReactNode; + onLazyLoad?(e: DataScrollerLazyLoadParams): void; } export declare class DataScroller extends React.Component {