@@ -8,6 +8,8 @@ import {ResponseError} from '../Errors/ResponseError';
88
99import { usePaginatedTableState } from './PaginatedTableContext' ;
1010import { EmptyTableRow , LoadingTableRow , TableRow } from './TableRow' ;
11+ import type { PaginatedTableId } from './constants' ;
12+ import { shouldSendColumnIds } from './constants' ;
1113import i18n from './i18n' ;
1214import type {
1315 Column ,
@@ -32,7 +34,7 @@ interface TableChunkProps<T, F> {
3234 sortParams ?: SortParams ;
3335 shouldFetch : boolean ;
3436 shouldRender : boolean ;
35- tableName : string ;
37+ tableName : PaginatedTableId ;
3638
3739 fetchData : FetchData < T , F > ;
3840 getRowClassName ?: GetRowClassName < T > ;
@@ -41,7 +43,6 @@ interface TableChunkProps<T, F> {
4143 onDataFetched : ( data ?: PaginatedTableData < T > ) => void ;
4244
4345 keepCache ?: boolean ;
44- useColumnsIdsInRequest ?: boolean ;
4546}
4647
4748// Memoisation prevents chunks rerenders that could cause perfomance issues on big tables
@@ -62,17 +63,18 @@ export const TableChunk = typedMemo(function TableChunk<T, F>({
6263 shouldFetch,
6364 shouldRender,
6465 keepCache,
65- useColumnsIdsInRequest,
6666} : TableChunkProps < T , F > ) {
6767 const [ isTimeoutActive , setIsTimeoutActive ] = React . useState ( true ) ;
6868 const [ autoRefreshInterval ] = useAutoRefreshInterval ( ) ;
6969 const { noBatching} = usePaginatedTableState ( ) ;
7070
71+ const preserveColsOrderInRequest = shouldSendColumnIds ( tableName ) ;
72+
7173 const columnsIds = React . useMemo (
7274 ( ) =>
7375 //sort ids to prevent refetch if only order was changed
74- useColumnsIdsInRequest ? columns . map ( ( column ) => column . name ) . toSorted ( ) : [ ] ,
75- [ columns , useColumnsIdsInRequest ] ,
76+ preserveColsOrderInRequest ? columns . map ( ( column ) => column . name ) . toSorted ( ) : [ ] ,
77+ [ columns , preserveColsOrderInRequest ] ,
7678 ) ;
7779
7880 const queryParams = {
0 commit comments