@@ -51,6 +51,7 @@ import { PROJECT_TABS } from '~/lib/constants'
5151import { Entry } from '~/lib/models/Entry'
5252import Button from '~/ui/Button'
5353import Dropdown from '~/ui/Dropdown'
54+ import InfiniteScrollTrigger from '~/ui/InfiniteScrollTrigger'
5455import Input from '~/ui/Input'
5556import Sort from '~/ui/icons/Sort'
5657import Spin from '~/ui/icons/Spin'
@@ -1834,7 +1835,7 @@ export interface PanelProps {
18341835 isRefetching ?: boolean
18351836 /** Shows a centered spinner in place of the rows while the first page is being fetched. */
18361837 isLoading ?: boolean
1837- serverTotal ?: number
1838+ /** Defined only while further pages remain; the details table autoloads them on scroll. */
18381839 onLoadMore ?: ( ) => void
18391840 loadingMore ?: boolean
18401841}
@@ -1851,7 +1852,6 @@ interface DetailsTableProps extends Pick<
18511852 | 'valueMapper'
18521853 | 'getFilterLink'
18531854 | 'activeTab'
1854- | 'serverTotal'
18551855 | 'onLoadMore'
18561856 | 'loadingMore'
18571857> {
@@ -1883,7 +1883,6 @@ const DetailsTable = ({
18831883 hidePercentageInDetails,
18841884 detailsExtraColumns,
18851885 activeTab = PROJECT_TABS . traffic ,
1886- serverTotal,
18871886 onLoadMore,
18881887 loadingMore,
18891888} : DetailsTableProps ) => {
@@ -2003,13 +2002,15 @@ const DetailsTable = ({
20032002 } )
20042003 }
20052004
2005+ // Keyed on the dimension, not on `data` — appending a page gives `data` a new
2006+ // identity, and resetting on that would undo the user's sort mid-scroll.
20062007 useEffect ( ( ) => {
20072008 setSort ( {
20082009 label : 'quantity' ,
20092010 sortByAscend : false ,
20102011 sortByDescend : false ,
20112012 } )
2012- } , [ data ] )
2013+ } , [ activeTabId ] )
20132014
20142015 const numericColsCount =
20152016 1 + ( detailsExtraColumns ?. length || 0 ) + ( ! hidePercentageInDetails ? 1 : 0 )
@@ -2209,28 +2210,17 @@ const DetailsTable = ({
22092210 )
22102211 } ) }
22112212 </ div >
2212- </ div >
2213- </ div >
2214- { onLoadMore ? (
2215- < div className = 'mt-2 flex items-center justify-center gap-3' >
2216- < Button
2217- variant = 'secondary'
2218- size = 'sm'
2219- type = 'button'
2220- onClick = { onLoadMore }
2221- disabled = { loadingMore }
2222- className = 'gap-1.5'
2223- >
2224- { loadingMore ? < Spin className = 'm-0!' /> : null }
2225- { t ( 'project.loadMore' ) }
2226- </ Button >
2227- { serverTotal ? (
2228- < Text size = 'sm' colour = 'muted' >
2229- { data . length } / { nFormatter ( serverTotal , 1 ) }
2230- </ Text >
2213+
2214+ { onLoadMore ? (
2215+ < InfiniteScrollTrigger
2216+ hasMore
2217+ isLoading = { Boolean ( loadingMore ) }
2218+ onLoadMore = { onLoadMore }
2219+ root = { parentRef }
2220+ />
22312221 ) : null }
22322222 </ div >
2233- ) : null }
2223+ </ div >
22342224 </ div >
22352225 )
22362226}
@@ -2265,7 +2255,6 @@ const Panel = ({
22652255 rowTooltipFollowCursor = false ,
22662256 isRefetching,
22672257 isLoading,
2268- serverTotal,
22692258 onLoadMore,
22702259 loadingMore,
22712260} : PanelProps ) => {
@@ -2720,7 +2709,6 @@ const Panel = ({
27202709 hidePercentageInDetails = { hidePercentageInDetails }
27212710 detailsExtraColumns = { detailsExtraColumns }
27222711 activeTab = { activeTab }
2723- serverTotal = { serverTotal }
27242712 onLoadMore = { onLoadMore }
27252713 loadingMore = { loadingMore }
27262714 />
0 commit comments