Skip to content

Commit

Permalink
fix(ui-tablemode): remove blank space at the bottom
Browse files Browse the repository at this point in the history
  • Loading branch information
skamril committed Jan 29, 2025
1 parent e5dd72a commit f476c88
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
19 changes: 14 additions & 5 deletions webapp/src/components/common/DataGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export interface DataGridProps extends Omit<DataEditorProps, "rowMarkers" | "gri
enableColumnResize?: boolean;
}

const ROW_HEIGHT = 30;
const OVERSCROLL = 2;

function isStringRowMarkerOptions(
rowMarkerOptions: RowMarkersOptions,
): rowMarkerOptions is StringRowMarkerOptions {
Expand Down Expand Up @@ -72,6 +75,11 @@ function DataGrid({
const isStringRowMarkers = isStringRowMarkerOptions(rowMarkersOptions);
const adjustedFreezeColumns = isStringRowMarkers ? (freezeColumns || 0) + 1 : freezeColumns;

// Manually calculate the height allows to remove the blank space at the bottom of the grid
// when there is no scrollbar. Header is included in the height calculation.
//! Group header is not included, fix it when needed.
const height = ROW_HEIGHT * (rows + 1) + OVERSCROLL;

const [columns, setColumns] = useState(initColumns);
const [gridSelection, setGridSelection] = useState<GridSelection>({
rows: CompactSelection.empty(),
Expand Down Expand Up @@ -268,14 +276,15 @@ function DataGrid({

return (
<DataEditor
groupHeaderHeight={30}
headerHeight={30}
rowHeight={30}
groupHeaderHeight={ROW_HEIGHT}
headerHeight={ROW_HEIGHT}
rowHeight={ROW_HEIGHT}
smoothScrollX
smoothScrollY
overscrollX={2}
overscrollY={2}
overscrollX={OVERSCROLL}
overscrollY={OVERSCROLL}
width="100%"
height={height}
theme={darkTheme}
{...rest}
rows={rows}
Expand Down
1 change: 0 additions & 1 deletion webapp/src/components/common/DataGridForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ function DataGridForm<TData extends Data>({
mt: 1.5,
}}
>
<Divider flexItem />
<Box sx={{ display: "flex" }}>
<LoadingButton
type="submit"
Expand Down

0 comments on commit f476c88

Please sign in to comment.