@@ -4,9 +4,7 @@ import {TableWithControlsLayout} from '../TableWithControlsLayout/TableWithContr
44
55import { TableChunk } from './TableChunk' ;
66import { TableHead } from './TableHead' ;
7- import { EmptyTableRow } from './TableRow' ;
87import { DEFAULT_TABLE_ROW_HEIGHT } from './constants' ;
9- import i18n from './i18n' ;
108import { b } from './shared' ;
119import type {
1210 Column ,
@@ -75,10 +73,14 @@ export const PaginatedTable = <T, F>({
7573 chunkSize,
7674 } ) ;
7775
78- const lastChunkSize = React . useMemo (
79- ( ) => foundEntities % chunkSize || chunkSize ,
80- [ foundEntities , chunkSize ] ,
81- ) ;
76+ const lastChunkSize = React . useMemo ( ( ) => {
77+ // If foundEntities = 0, there will only first chunk
78+ // Display it with 1 row, to display empty data message
79+ if ( ! foundEntities ) {
80+ return 1 ;
81+ }
82+ return foundEntities % chunkSize || chunkSize ;
83+ } , [ foundEntities , chunkSize ] ) ;
8284
8385 const handleDataFetched = React . useCallback ( ( total : number , found : number ) => {
8486 setTotalEntities ( total ) ;
@@ -97,16 +99,6 @@ export const PaginatedTable = <T, F>({
9799 } , [ filters , initialFound , initialTotal , parentRef ] ) ;
98100
99101 const renderChunks = ( ) => {
100- if ( ! isInitialLoad && foundEntities === 0 ) {
101- return (
102- < tbody >
103- < EmptyTableRow columns = { columns } >
104- { renderEmptyDataMessage ? renderEmptyDataMessage ( ) : i18n ( 'empty' ) }
105- </ EmptyTableRow >
106- </ tbody >
107- ) ;
108- }
109-
110102 return activeChunks . map ( ( isActive , index ) => (
111103 < TableChunk < T , F >
112104 key = { index }
@@ -121,6 +113,7 @@ export const PaginatedTable = <T, F>({
121113 sortParams = { sortParams }
122114 getRowClassName = { getRowClassName }
123115 renderErrorMessage = { renderErrorMessage }
116+ renderEmptyDataMessage = { renderEmptyDataMessage }
124117 onDataFetched = { handleDataFetched }
125118 isActive = { isActive }
126119 />
0 commit comments