Skip to content

Commit

Permalink
fix(ui-commons): use props values to calculate the height
Browse files Browse the repository at this point in the history
  • Loading branch information
skamril committed Jan 30, 2025
1 parent be08fb8 commit e82ddbb
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions webapp/src/components/common/DataGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export interface DataGridProps extends Omit<DataEditorProps, "rowMarkers" | "gri
}

const ROW_HEIGHT = 30;
const OVERSCROLL = 2;

function isStringRowMarkerOptions(
rowMarkerOptions: RowMarkersOptions,
Expand Down Expand Up @@ -75,11 +74,6 @@ 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 @@ -281,12 +275,8 @@ function DataGrid({
rowHeight={ROW_HEIGHT}
smoothScrollX
smoothScrollY
overscrollX={OVERSCROLL}
overscrollY={OVERSCROLL}
width="100%"
height={height}
theme={darkTheme}
{...rest}
rows={rows}
columns={columns}
rowMarkers={isStringRowMarkers ? "none" : rowMarkersOptions}
Expand All @@ -299,6 +289,7 @@ function DataGrid({
gridSelection={gridSelection}
onGridSelectionChange={handleGridSelectionChange}
freezeColumns={adjustedFreezeColumns}
{...rest}
/>
);
}
Expand Down

0 comments on commit e82ddbb

Please sign in to comment.