Skip to content

Commit 6fea4b9

Browse files
committed
fix: scroll to 0
1 parent 35d54a3 commit 6fea4b9

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

src/components/PaginatedTable/PaginatedTable.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,9 @@ import type {
1919
SortParams,
2020
} from './types';
2121
import {useScrollBasedChunks} from './useScrollBasedChunks';
22-
import {calculateElementOffsetTop} from './utils';
2322

2423
import './PaginatedTable.scss';
2524

26-
const HEADER_HEIGHT = 40;
27-
const CONTROLS_HEIGHT = 50;
28-
2925
export interface PaginatedTableProps<T, F> {
3026
limit: number;
3127
initialEntitiesCount?: number;
@@ -87,15 +83,12 @@ export const PaginatedTable = <T, F>({
8783

8884
// reset table on filters change
8985
React.useLayoutEffect(() => {
90-
if (parentRef?.current && tableRef.current && !initialTotal) {
91-
parentRef.current.scrollTo({
92-
left: 0,
93-
top: calculateElementOffsetTop(tableRef.current) - HEADER_HEIGHT - CONTROLS_HEIGHT,
94-
});
95-
}
9686
setTotalEntities(initialTotal);
9787
setFoundEntities(initialFound);
9888
setIsInitialLoad(true);
89+
if (parentRef?.current) {
90+
parentRef.current.scrollTo(0, 0);
91+
}
9992
}, [filters, initialFound, initialTotal, parentRef]);
10093

10194
const renderChunks = () => {

0 commit comments

Comments
 (0)