Skip to content

Commit af1a719

Browse files
FelixMalfaitWeiko
authored andcommitted
Improve autoload (#5566)
Set a 1000px margin to start fetching more records before we hit the bottom of the page, makes the scrolling experience a lot smoother :)
1 parent fe141df commit af1a719

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

packages/twenty-front/src/modules/object-record/record-table/components/RecordTableBodyFetchMoreLoader.tsx

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useContext } from 'react';
12
import { useInView } from 'react-intersection-observer';
23
import styled from '@emotion/styled';
34
import { useRecoilCallback, useRecoilValue } from 'recoil';
@@ -6,6 +7,7 @@ import { useLoadRecordIndexTable } from '@/object-record/record-index/hooks/useL
67
import { useRecordTable } from '@/object-record/record-table/hooks/useRecordTable';
78
import { isFetchingMoreRecordsFamilyState } from '@/object-record/states/isFetchingMoreRecordsFamilyState';
89
import { GRAY_SCALE } from '@/ui/theme/constants/GrayScale';
10+
import { ScrollWrapperContext } from '@/ui/utilities/scroll/components/ScrollWrapper';
911

1012
type RecordTableBodyFetchMoreLoaderProps = {
1113
objectNameSingular: string;
@@ -38,8 +40,14 @@ export const RecordTableBodyFetchMoreLoader = ({
3840
[setRecordTableLastRowVisible],
3941
);
4042

43+
const scrollWrapperRef = useContext(ScrollWrapperContext);
44+
4145
const { ref: tbodyRef } = useInView({
4246
onChange: onLastRowVisible,
47+
rootMargin: '1000px',
48+
root: scrollWrapperRef.current?.querySelector(
49+
'[data-overlayscrollbars-viewport="scrollbarHidden"]',
50+
),
4351
});
4452

4553
return (

0 commit comments

Comments
 (0)