Skip to content

Commit

Permalink
Reset selection on pagination change
Browse files Browse the repository at this point in the history
  • Loading branch information
ruscoder committed Dec 6, 2024
1 parent a6f41a4 commit bfdfd08
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/uberComponents/ResourceListPage/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { TablePaginationConfig } from 'antd';
import { Bundle, Resource } from 'fhir/r4b';
import { useEffect, useMemo, useState } from 'react';

Expand Down Expand Up @@ -29,10 +30,22 @@ export function useResourceListPage<R extends Resource>(
};
const searchParams = { _sort: '-_lastUpdated', ...defaultSearchParams, ...searchBarSearchParams };

const { resourceResponse, pagerManager, handleTableChange, pagination } = usePagerExtended<R, ColumnFilterValue[]>(
resourceType,
searchParams,
);
const {
resourceResponse,
pagerManager,
handleTableChange: pagerHandleTableChange,
pagination,
} = usePagerExtended<R, ColumnFilterValue[]>(resourceType, searchParams);

const handleTableChange = async (pagination: TablePaginationConfig) => {
// Handle pagination only
if (typeof pagination.current !== 'number') {
return;
}

pagerHandleTableChange(pagination);
setSelectedRowKeys([]);
};

useEffect(() => {
setSelectedRowKeys([]);
Expand Down

0 comments on commit bfdfd08

Please sign in to comment.