From be6a651e2fd4f65a3462e84c79b5dc5261df69ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frane=20Poli=C4=87?= <16856471+fPolic@users.noreply.github.com> Date: Fri, 28 Mar 2025 08:58:33 +0100 Subject: [PATCH] fix(dashboard): notification list scroll flickering (#11911) * fix: flicekring of the notification list due to rerendering * fix: revert page size * fix: page size * fix: reintroduce treshold * fix: param * fix: revert page size --- .../common/infinite-list/infinite-list.tsx | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/packages/admin/dashboard/src/components/common/infinite-list/infinite-list.tsx b/packages/admin/dashboard/src/components/common/infinite-list/infinite-list.tsx index 49d52642d9..612fb4503d 100644 --- a/packages/admin/dashboard/src/components/common/infinite-list/infinite-list.tsx +++ b/packages/admin/dashboard/src/components/common/infinite-list/infinite-list.tsx @@ -74,17 +74,27 @@ export const InfiniteList = < // Define the new observers after we stop fetching if (!isFetching) { // Define the new observers after paginating - startObserver.current = new IntersectionObserver((entries) => { - if (entries[0].isIntersecting && hasPreviousPage) { - fetchPreviousPage() + startObserver.current = new IntersectionObserver( + (entries) => { + if (entries[0].isIntersecting && hasPreviousPage) { + fetchPreviousPage() + } + }, + { + threshold: 0.5, } - }) + ) - endObserver.current = new IntersectionObserver((entries) => { - if (entries[0].isIntersecting && hasNextPage) { - fetchNextPage() + endObserver.current = new IntersectionObserver( + (entries) => { + if (entries[0].isIntersecting && hasNextPage) { + fetchNextPage() + } + }, + { + threshold: 0.5, } - }) + ) // Register the new observers to observe the new first and last children startObserver.current?.observe(parentRef.current!.firstChild as Element)