reset scroll position on list page change

This commit is contained in:
jeffvli
2025-10-23 00:50:24 -07:00
parent dae04e2aeb
commit 34dc917271
6 changed files with 37 additions and 2 deletions
@@ -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: () => {