mirror of
https://github.com/jeffvli/feishin.git
synced 2026-06-15 16:04:19 +02:00
reset scroll position on list page change
This commit is contained in:
@@ -403,6 +403,7 @@ interface ItemTableListProps {
|
||||
CellComponent: JSXElementConstructor<CellComponentProps<TableItemProps>>;
|
||||
cellPadding?: 'lg' | 'md' | 'sm' | 'xl' | 'xs';
|
||||
columns: ItemTableListColumnConfig[];
|
||||
currentPage?: number;
|
||||
data: unknown[];
|
||||
enableAlternateRowColors?: boolean;
|
||||
enableExpansion?: boolean;
|
||||
@@ -435,6 +436,7 @@ export const ItemTableList = ({
|
||||
CellComponent,
|
||||
cellPadding = 'sm',
|
||||
columns,
|
||||
currentPage,
|
||||
data,
|
||||
enableAlternateRowColors = false,
|
||||
enableExpansion = true,
|
||||
@@ -1079,6 +1081,13 @@ export const ItemTableList = ({
|
||||
}
|
||||
}, [initialTop, scrollToTableIndex, scrollToTableOffset]);
|
||||
|
||||
// Scroll to top when currentPage changes
|
||||
useEffect(() => {
|
||||
if (currentPage !== undefined) {
|
||||
scrollToTableOffset(0);
|
||||
}
|
||||
}, [currentPage, scrollToTableOffset]);
|
||||
|
||||
const imperativeHandle: ItemListHandle = useMemo(() => {
|
||||
return {
|
||||
clearExpanded: () => {
|
||||
|
||||
Reference in New Issue
Block a user