diff --git a/src/components/ResourceList/HorizontalPaginationList.tsx b/src/components/ResourceList/HorizontalPaginationList.tsx index dce68b6..fb60a66 100644 --- a/src/components/ResourceList/HorizontalPaginationList.tsx +++ b/src/components/ResourceList/HorizontalPaginationList.tsx @@ -65,7 +65,13 @@ const displayedItems = disablePagination ? items : items?.length < (displayedLim width: '100%', display: 'flex', justifyContent: 'center' - }} ref={index === displayedLimit ? lastItemRef2 : index === list.length -displayedLimit - 1 ? lastItemRef : null}> + }} ref={ + index === displayedLimit + ? lastItemRef2 + : index === (list.length - displayedLimit - 1 < displayedLimit ? displayedLimit - 1 : list.length - displayedLimit - 1 ) + ? lastItemRef + : null + }> { await onLoadMore(displayedLimit); + if(!disablePagination && (displayedItems?.length === displayedLimit * 3)){ lastItemRef.current.scrollIntoView({ behavior: "auto", block: "end" }); setTimeout(() => { window.scrollBy({ top: 50, behavior: "instant" }); // 'smooth' if needed }, 0); - + } }} /> )} diff --git a/src/components/ResourceList/VerticalPaginationList.tsx b/src/components/ResourceList/VerticalPaginationList.tsx index 4e53941..1cf6635 100644 --- a/src/components/ResourceList/VerticalPaginationList.tsx +++ b/src/components/ResourceList/VerticalPaginationList.tsx @@ -40,7 +40,8 @@ export const VerticalPaginatedList = ({ const displayedItems = disablePagination ? items - : items.slice(-(displayedLimit * 3)); + : items?.length < (displayedLimit * 3) ? items?.slice(0, displayedLimit * 3) : items.slice(- (displayedLimit * 3)); + return ( <> @@ -60,6 +61,7 @@ export const VerticalPaginatedList = ({ )} {displayedItems?.map((item, index, list) => { + return ( { await onLoadMore(displayedLimit); - lastItemRef.current.scrollIntoView({ - behavior: "auto", - block: "end", - }); - setTimeout(() => { - window.scrollBy({ top: 50, behavior: "instant" }); // 'smooth' if needed - }, 0); + if(!disablePagination && (displayedItems?.length === displayedLimit * 3)){ + lastItemRef.current.scrollIntoView({ + behavior: "auto", + block: "end", + }); + setTimeout(() => { + window.scrollBy({ top: 50, behavior: "instant" }); // 'smooth' if needed + }, 0); + } + }} /> )}