Skip to content

Commit b845b56

Browse files
committed
fix: one tbody for all
1 parent d3fb642 commit b845b56

File tree

3 files changed

+17
-32
lines changed

3 files changed

+17
-32
lines changed

src/components/PaginatedTable/PaginatedTable.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,9 @@ export const PaginatedTable = <T, F>({
183183

184184
// Render merged empty tbody for consecutive inactive chunks
185185
chunks.push(
186-
<tbody key={`merged-${startIndex}-${i - 1}`}>
187-
<tr style={{height: `${totalHeight}px`}}>
188-
<td colSpan={columns.length} style={{padding: 0, border: 'none'}} />
189-
</tr>
190-
</tbody>,
186+
<tr style={{height: `${totalHeight}px`}} key={`merged-${startIndex}-${i - 1}`}>
187+
<td colSpan={columns.length} style={{padding: 0, border: 'none'}} />
188+
</tr>,
191189
);
192190
}
193191
}
@@ -198,7 +196,7 @@ export const PaginatedTable = <T, F>({
198196
const renderTable = () => (
199197
<table className={b('table')}>
200198
<TableHead columns={columns} onSort={setSortParams} onColumnsResize={onColumnsResize} />
201-
{renderChunks()}
199+
<tbody>{renderChunks()}</tbody>
202200
</table>
203201
);
204202

src/components/PaginatedTable/TableChunk.tsx

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,11 @@ export const TableChunk = typedMemo(function TableChunk<T, F>({
112112
const dataLength = currentData?.data?.length || calculatedCount;
113113

114114
const renderContent = () => {
115-
if (!shouldRender) {
116-
return null;
117-
}
118-
119115
if (!currentData) {
120116
if (error) {
121117
const errorData = error as IResponseError;
122118
return (
123-
<EmptyTableRow columns={columns}>
119+
<EmptyTableRow columns={columns} height={dataLength * rowHeight}>
124120
{renderErrorMessage ? (
125121
renderErrorMessage(errorData)
126122
) : (
@@ -138,7 +134,7 @@ export const TableChunk = typedMemo(function TableChunk<T, F>({
138134
// Data is loaded, but there are no entities in the chunk
139135
if (!currentData.data?.length) {
140136
return (
141-
<EmptyTableRow columns={columns}>
137+
<EmptyTableRow columns={columns} height={dataLength * rowHeight}>
142138
{renderEmptyDataMessage ? renderEmptyDataMessage() : i18n('empty')}
143139
</EmptyTableRow>
144140
);
@@ -155,21 +151,11 @@ export const TableChunk = typedMemo(function TableChunk<T, F>({
155151
));
156152
};
157153

158-
return (
159-
<tbody
160-
id={id.toString()}
161-
style={{
162-
height: `${dataLength * rowHeight}px`,
163-
display: 'table-row-group',
164-
}}
165-
>
166-
{shouldRender ? (
167-
renderContent()
168-
) : (
169-
<tr style={{height: `${dataLength * rowHeight}px`}}>
170-
<td colSpan={columns.length} style={{padding: 0, border: 'none'}} />
171-
</tr>
172-
)}
173-
</tbody>
154+
return shouldRender ? (
155+
renderContent()
156+
) : (
157+
<tr style={{height: `${dataLength * rowHeight}px`}}>
158+
<td colSpan={columns.length} style={{padding: 0, border: 'none'}} />
159+
</tr>
174160
);
175161
});

src/components/PaginatedTable/TableRow.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ interface LoadingTableRowProps<T> {
4444

4545
export const LoadingTableRow = typedMemo(function <T>({columns, height}: LoadingTableRowProps<T>) {
4646
return (
47-
<tr className={b('row', {loading: true})}>
47+
<tr className={b('row', {loading: true})} style={{height}}>
4848
{columns.map((column) => {
4949
const resizeable = column.resizeable ?? DEFAULT_RESIZEABLE;
5050

@@ -79,7 +79,7 @@ export const TableRow = <T,>({row, columns, getRowClassName, height}: TableRowPr
7979
const additionalClassName = getRowClassName?.(row);
8080

8181
return (
82-
<tr className={b('row', additionalClassName)}>
82+
<tr className={b('row', additionalClassName)} style={{height}}>
8383
{columns.map((column) => {
8484
const resizeable = column.resizeable ?? DEFAULT_RESIZEABLE;
8585

@@ -103,11 +103,12 @@ export const TableRow = <T,>({row, columns, getRowClassName, height}: TableRowPr
103103
interface EmptyTableRowProps<T> {
104104
columns: Column<T>[];
105105
children?: React.ReactNode;
106+
height: number;
106107
}
107108

108-
export const EmptyTableRow = <T,>({columns, children}: EmptyTableRowProps<T>) => {
109+
export const EmptyTableRow = <T,>({columns, children, height}: EmptyTableRowProps<T>) => {
109110
return (
110-
<tr className={b('row', {empty: true})}>
111+
<tr className={b('row', {empty: true})} style={{height}}>
111112
<td colSpan={columns.length} className={b('td')}>
112113
{children}
113114
</td>

0 commit comments

Comments
 (0)