Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

fix(tables): a table without infinite scroll keeps its scroll position when the URL search changes

aashu25a00964e241
diff --git a/apps/erp/app/components/Table/useInfiniteScroll.ts b/apps/erp/app/components/Table/useInfiniteScroll.ts
index 5a76a5cbab..a3deb74521 100644
--- a/apps/erp/app/components/Table/useInfiniteScroll.ts
+++ b/apps/erp/app/components/Table/useInfiniteScroll.ts
@@ -111,13 +111,15 @@ export function useInfiniteScroll(
element.scrollTop = clampScrollTop(restoredScrollTop, element);
}, [root, sentinel, hasRows, restoredScrollTop]);
- // A new list starts at the top.
+ // A new list starts at the top. A table that is not infinite keeps its
+ // scroll: its reset key follows every search param, not only its own.
const resetKey = rows?.resetKey;
const resetKeyRef = useRef(resetKey);
// biome-ignore lint/correctness/useExhaustiveDependencies: runs when the list changes only
useEffect(() => {
if (resetKeyRef.current === resetKey) return;
resetKeyRef.current = resetKey;
+ if (!isOn) return;
resolveRoot(root, sentinel)?.scrollTo({ top: 0 });
}, [resetKey]);