Skip to content

Commit 5aa18c3

Browse files
committed
feat(inboxes): make table take all the space and pagination sticky
1 parent 8f04e70 commit 5aa18c3

2 files changed

Lines changed: 30 additions & 13 deletions

File tree

packages/app-builder/src/components/Cases/CasesList.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import clsx from 'clsx';
1313
import { differenceInDays } from 'date-fns/differenceInDays';
1414
import { useEffect, useMemo, useState } from 'react';
1515
import { useTranslation } from 'react-i18next';
16-
import { Table, Tooltip, useVirtualTable } from 'ui-design-system';
16+
import { Table, Tooltip, useTable } from 'ui-design-system';
1717

1818
import { CaseAssignedTo } from './CaseAssignedTo';
1919
import { CaseContributors } from './CaseContributors';
@@ -139,7 +139,7 @@ export function CasesList({
139139
[language, t, orgTags],
140140
);
141141

142-
const { table, getBodyProps, rows, getContainerProps, scrollToTop } = useVirtualTable({
142+
const { table, getBodyProps, rows, getContainerProps } = useTable({
143143
data: cases,
144144
columns,
145145
columnResizeMode: 'onChange',
@@ -151,10 +151,6 @@ export function CasesList({
151151
rowLink: ({ id }) => <Link to={getRoute('/cases/:caseId', { caseId: fromUUIDtoSUUID(id) })} />,
152152
});
153153

154-
useEffect(() => {
155-
scrollToTop();
156-
}, [cases]);
157-
158154
return (
159155
<Table.Container {...getContainerProps()} className={clsx('bg-grey-100', className)}>
160156
<Table.Header headerGroups={table.getHeaderGroups()} />

packages/app-builder/src/routes/_builder+/cases+/inboxes.$inboxId.tsx

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
} from '@app-builder/components/Cases/Filters';
1010
import { InputWithButton } from '@app-builder/components/InputWithButton';
1111
import { useCursorPaginatedFetcher } from '@app-builder/hooks/useCursorPaginatedFetcher';
12+
import useIntersection from '@app-builder/hooks/useIntersection';
1213
import { isForbiddenHttpError, isNotFoundHttpError } from '@app-builder/models';
1314
import { type Case, type CaseStatus, caseStatuses } from '@app-builder/models/cases';
1415
import { type PaginatedResponse, type PaginationParams } from '@app-builder/models/pagination';
@@ -25,7 +26,7 @@ import { type LoaderFunctionArgs, redirect } from '@remix-run/node';
2526
import { useLoaderData, useNavigate } from '@remix-run/react';
2627
import { type Namespace } from 'i18next';
2728
import qs from 'qs';
28-
import { useCallback } from 'react';
29+
import { useCallback, useEffect, useRef } from 'react';
2930
import { useTranslation } from 'react-i18next';
3031
import { omit } from 'remeda';
3132
import { Button, cn } from 'ui-design-system';
@@ -212,11 +213,23 @@ export default function Cases() {
212213
[navigate, inboxId, next, previous, reset],
213214
);
214215

216+
const paginationSentinelRef = useRef<HTMLDivElement>(null);
217+
const containerRef = useRef<HTMLDivElement>(null);
218+
const paginationIntersection = useIntersection(paginationSentinelRef, {
219+
root: containerRef.current,
220+
rootMargin: '-24px',
221+
threshold: 0,
222+
});
223+
224+
useEffect(() => {
225+
containerRef.current?.scrollTo({ top: 0 });
226+
}, [cases]);
227+
215228
return (
216229
<CaseRightPanel.Root>
217-
<Page.Container>
218-
<Page.Content>
219-
<div className="flex flex-col gap-4">
230+
<Page.Container ref={containerRef}>
231+
<Page.ContentV2>
232+
<div className="flex flex-col gap-4 relative">
220233
<CasesFiltersProvider submitCasesFilters={navigateCasesList} filterValues={filters}>
221234
<div className="flex justify-between">
222235
<div className="flex gap-4 items-center">
@@ -262,7 +275,6 @@ export default function Cases() {
262275
<CasesList
263276
key={inboxId}
264277
cases={cases}
265-
className="max-h-[60dvh]"
266278
initSorting={[
267279
{
268280
id: initialPagination.sorting ?? 'created_at',
@@ -279,7 +291,15 @@ export default function Cases() {
279291
hasAlreadyOrdered = true;
280292
}}
281293
/>
282-
<div className="flex justify-between gap-8">
294+
<div
295+
className={cn(
296+
'flex justify-between gap-8 sticky bottom-0 z-10 bg-purple-99 -mb-v2-lg -mx-v2-lg p-v2-lg pt-v2-md border-t border-purple-99',
297+
{
298+
'shadow-sticky-bottom border-t-grey-95':
299+
!paginationIntersection?.isIntersecting,
300+
},
301+
)}
302+
>
283303
<div className="flex gap-2 items-center">
284304
<span>{t('cases:list.results_per_page')}</span>
285305
{[25, 50, 100].map((limit) => {
@@ -313,8 +333,9 @@ export default function Cases() {
313333
/>
314334
</div>
315335
</CasesFiltersProvider>
336+
<div ref={paginationSentinelRef} className="absolute left-0 bottom-0" />
316337
</div>
317-
</Page.Content>
338+
</Page.ContentV2>
318339
</Page.Container>
319340
</CaseRightPanel.Root>
320341
);

0 commit comments

Comments
 (0)