Set reasonable table height (#11998)
This commit is contained in:
parent
6530052471
commit
dd1edce2e5
|
|
@ -813,6 +813,14 @@ export function InvenTreeTableInternal<T extends Record<string, any>>({
|
||||||
);
|
);
|
||||||
}, [tableProps.onCellClick, tableProps.onRowClick, tableProps.modelType]);
|
}, [tableProps.onCellClick, tableProps.onRowClick, tableProps.modelType]);
|
||||||
|
|
||||||
|
// When sticky headers are enabled, we adjust the maximum viewport height,
|
||||||
|
// based on the number of records being displayed (up to a maximum of 60vh)
|
||||||
|
const autoHeight = useMemo(() => {
|
||||||
|
const rows = Math.max(10, Math.min(tableState.records.length, 60));
|
||||||
|
|
||||||
|
return `${rows}vh`;
|
||||||
|
}, [tableState.records]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack gap='xs'>
|
<Stack gap='xs'>
|
||||||
|
|
@ -838,7 +846,8 @@ export function InvenTreeTableInternal<T extends Record<string, any>>({
|
||||||
stickyHeader: stickyTableHeader ? 'top' : undefined
|
stickyHeader: stickyTableHeader ? 'top' : undefined
|
||||||
}}
|
}}
|
||||||
height={
|
height={
|
||||||
tableProps.height ?? (stickyTableHeader ? '80vh' : undefined)
|
tableProps.height ??
|
||||||
|
(stickyTableHeader ? autoHeight : undefined)
|
||||||
}
|
}
|
||||||
withTableBorder={!tableProps.noHeader}
|
withTableBorder={!tableProps.noHeader}
|
||||||
withColumnBorders
|
withColumnBorders
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue