mirror of
https://github.com/inventree/InvenTree.git
synced 2026-05-28 03:49:20 +00:00
Set reasonable table height (#11998)
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user