-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[DataGridPro] Use intersection observer to trigger server-side infinite loading #17369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Deploy preview: https://deploy-preview-17369--material-ui-x.netlify.app/ |
1bc8f2e
to
9615558
Compare
* Used to trigger infinite loading. | ||
* @ignore - do not document. | ||
*/ | ||
onIntersection: {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Event names usually don't contain "on", it's the handler which contains it. For example, "click" event, and the corresponding handler would be "onclick". How about making it "intersectionObserved" or simply "intersection"?
onIntersection: {}; | |
intersection: {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps calling it rowsScrollEndIntersection
would be more meaningful?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would go for intersection
because this hook does not know where the trigger element is placed
Update:
Well, this is not entirely true
hook is using scrollEndThreshold
prop and adding bottom margin to adjust the intersection area
so, even though you can place the element anywhere, it will not work anywhere
I will use rowsScrollEndIntersection
it is internal event anyway.
once/if we decide to make it generic, we can change this alongside with the other suggestion from #17369 (comment)
in that case, the check #17369 (comment) should also be completely removed
packages/x-data-grid-pro/src/tests/dataSourceLazyLoader.DataGridPro.test.tsx
Outdated
Show resolved
Hide resolved
packages/x-data-grid-pro/src/tests/dataSourceLazyLoader.DataGridPro.test.tsx
Outdated
Show resolved
Hide resolved
packages/x-data-grid-pro/src/tests/dataSourceLazyLoader.DataGridPro.test.tsx
Outdated
Show resolved
Hide resolved
packages/x-data-grid-pro/src/tests/dataSourceLazyLoader.DataGridPro.test.tsx
Outdated
Show resolved
Hide resolved
...ages/x-data-grid-pro/src/hooks/features/serverSideLazyLoader/useGridIntersectionObserver.tsx
Outdated
Show resolved
Hide resolved
...ages/x-data-grid-pro/src/hooks/features/serverSideLazyLoader/useGridIntersectionObserver.tsx
Outdated
Show resolved
Hide resolved
9615558
to
77c3be8
Compare
packages/x-data-grid-pro/src/hooks/features/serverSideLazyLoader/useGridDataSourceLazyLoader.ts
Outdated
Show resolved
Hide resolved
...ages/x-data-grid-pro/src/hooks/features/serverSideLazyLoader/useGridIntersectionObserver.tsx
Outdated
Show resolved
Hide resolved
...ages/x-data-grid-pro/src/hooks/features/serverSideLazyLoader/useGridIntersectionObserver.tsx
Outdated
Show resolved
Hide resolved
4f54526
to
14c7c4d
Compare
I have extracted IntersectionObserver logic into a separate hook and moved it to the server side feature folder, since the client side feature is deprecated.
Both client and server side infinite loading are now listening to the new internal event from this hook to handle the data update
There are two main reasons for doing this: