fix(widgets): allow narrow Docker and downloads tables to scroll (#7067)
Related to #7058. Preserve readable table column widths and enable horizontal scrolling in narrow Docker and Downloads widgets.
This commit is contained in:
1 parent
29a422e4d8
commit
eb1d449dca
4 files changed
+15
-1
No files matched your search
@@ -15,6 +15,7 @@
|
|||||||
.homarr-data-table .mantine-datatable-table {
|
.homarr-data-table .mantine-datatable-table {
|
||||||
width: 100% !important;
|
width: 100% !important;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
|
min-width: var(--homarr-table-min-width, 0);
|
||||||
table-layout: fixed !important;
|
table-layout: fixed !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,12 +25,14 @@ type HomarrDataTableProps<T> = DataTableProps<T> & {
|
|||||||
isEditMode: boolean;
|
isEditMode: boolean;
|
||||||
cellPadding: string;
|
cellPadding: string;
|
||||||
rowCursor?: "auto" | "default";
|
rowCursor?: "auto" | "default";
|
||||||
|
preserveColumnWidths?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function HomarrDataTable<T>({
|
export function HomarrDataTable<T>({
|
||||||
isEditMode,
|
isEditMode,
|
||||||
cellPadding,
|
cellPadding,
|
||||||
rowCursor = "auto",
|
rowCursor = "auto",
|
||||||
|
preserveColumnWidths = false,
|
||||||
className,
|
className,
|
||||||
columns,
|
columns,
|
||||||
defaultColumnProps,
|
defaultColumnProps,
|
||||||
@@ -132,6 +134,15 @@ export function HomarrDataTable<T>({
|
|||||||
});
|
});
|
||||||
}, [cellPadding, columns, defaultColumnProps?.cellsStyle, resizePreviewWidths]);
|
}, [cellPadding, columns, defaultColumnProps?.cellsStyle, resizePreviewWidths]);
|
||||||
|
|
||||||
|
const minimumTableWidth = useMemo(() => {
|
||||||
|
if (!preserveColumnWidths) return undefined;
|
||||||
|
const totalWidth = columns
|
||||||
|
.filter(({ hidden }) => !hidden)
|
||||||
|
.reduce((total, column) => total + getColumnWidth(column.width), 0);
|
||||||
|
// Keep the minimum readable in displayed pixels when the board canvas is zoomed.
|
||||||
|
return `calc(${totalWidth}px * var(--board-canvas-inverse-scale, 1))`;
|
||||||
|
}, [columns, preserveColumnWidths]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DataTable<T>
|
<DataTable<T>
|
||||||
withTableBorder={false}
|
withTableBorder={false}
|
||||||
@@ -147,7 +158,7 @@ export function HomarrDataTable<T>({
|
|||||||
columns={fittedColumns}
|
columns={fittedColumns}
|
||||||
onMouseDownCapture={handleMouseDownCapture}
|
onMouseDownCapture={handleMouseDownCapture}
|
||||||
className={mergedClassName}
|
className={mergedClassName}
|
||||||
style={[{ pointerEvents: isEditMode ? "none" : undefined }, style]}
|
style={[{ pointerEvents: isEditMode ? "none" : undefined, "--homarr-table-min-width": minimumTableWidth }, style]}
|
||||||
defaultColumnProps={{
|
defaultColumnProps={{
|
||||||
...defaultColumnProps,
|
...defaultColumnProps,
|
||||||
noWrap: defaultColumnProps?.noWrap ?? true,
|
noWrap: defaultColumnProps?.noWrap ?? true,
|
||||||
|
|||||||
@@ -425,6 +425,7 @@ export default function DockerWidget({
|
|||||||
<Stack gap={0} h="100%" style={{ overflow: "hidden" }}>
|
<Stack gap={0} h="100%" style={{ overflow: "hidden" }}>
|
||||||
<Box style={{ flex: 1, minHeight: 0 }}>
|
<Box style={{ flex: 1, minHeight: 0 }}>
|
||||||
<HomarrDataTable
|
<HomarrDataTable
|
||||||
|
preserveColumnWidths
|
||||||
isEditMode={isEditMode}
|
isEditMode={isEditMode}
|
||||||
cellPadding={isAdvanced || width < 400 ? "2px 8px" : "4px 8px"}
|
cellPadding={isAdvanced || width < 400 ? "2px 8px" : "4px 8px"}
|
||||||
className="docker-table"
|
className="docker-table"
|
||||||
|
|||||||
@@ -783,6 +783,7 @@ export default function DownloadClientsWidget({
|
|||||||
{queryIndicators}
|
{queryIndicators}
|
||||||
</Box>
|
</Box>
|
||||||
<HomarrDataTable
|
<HomarrDataTable
|
||||||
|
preserveColumnWidths
|
||||||
isEditMode={isEditMode}
|
isEditMode={isEditMode}
|
||||||
cellPadding={`${size.cellPadding}px 8px`}
|
cellPadding={`${size.cellPadding}px 8px`}
|
||||||
fetching={isFetching && (currentItems?.length ?? 0) === 0}
|
fetching={isFetching && (currentItems?.length ?? 0) === 0}
|
||||||
|
|||||||
Reference in new issue
Block a user