From 0ff15c6483e10ed2ea88ce08a49532cb4ba2e432 Mon Sep 17 00:00:00 2001 From: Samir Kamal <1954121+skamril@users.noreply.github.com> Date: Thu, 30 Jan 2025 10:42:38 +0100 Subject: [PATCH] fix(ui-commons): use props values to calculate the height --- webapp/src/components/common/DataGrid.tsx | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/webapp/src/components/common/DataGrid.tsx b/webapp/src/components/common/DataGrid.tsx index 39659f4e24..b0deb6fab7 100644 --- a/webapp/src/components/common/DataGrid.tsx +++ b/webapp/src/components/common/DataGrid.tsx @@ -26,6 +26,7 @@ import { useCallback, useState } from "react"; import { voidFn } from "@/utils/fnUtils"; import { darkTheme } from "./Matrix/styles"; import { useUpdateEffect } from "react-use"; +import * as RA from "ramda-adjunct"; interface StringRowMarkerOptions { kind: "string" | "clickable-string"; @@ -66,6 +67,10 @@ function DataGrid({ onGridSelectionChange, enableColumnResize = true, freezeColumns, + height: heightFromProps, + headerHeight = ROW_HEIGHT, + rowHeight = ROW_HEIGHT, + overscrollY = OVERSCROLL, rows, ...rest }: DataGridProps) { @@ -78,7 +83,10 @@ function DataGrid({ // 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 height = + RA.isUndefined(heightFromProps) && RA.isNumber(rowHeight) + ? rowHeight * rows + headerHeight + overscrollY + : heightFromProps; const [columns, setColumns] = useState(initColumns); const [gridSelection, setGridSelection] = useState({ @@ -277,16 +285,15 @@ function DataGrid({ return ( ); }