Skip to content

Commit

Permalink
Adds requested changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
natalyjazzviolin committed Feb 10, 2025
1 parent 6a77f93 commit 6378cf8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/components/Grid/Cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ export const Cell = memo(
const cellRef = useRef<HTMLDivElement>(null);

useEffect(() => {
if (!rowAutoHeight) return;
else if (cellRef.current) {
if (!rowAutoHeight) {return;}
if (cellRef.current) {
const height = cellRef.current.getBoundingClientRect().height;
updateRowHeight(rowIndex, height);
}
Expand Down
20 changes: 6 additions & 14 deletions src/components/Grid/Grid.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ describe("Grid", () => {
};

const renderGrid = ({
rowCount,
columnCount,
rowCount = 20,
columnCount = 20,
columnWidth,
onColumnResize,
focus,
Expand All @@ -82,8 +82,8 @@ describe("Grid", () => {
}: Props) =>
renderCUI(
<Grid
rowCount={rowCount ?? 20}
columnCount={columnCount ?? 20}
rowCount={rowCount}
columnCount={columnCount}
columnWidth={columnWidth ?? columnWidthTestFn}
cell={Cell}
focus={focus ?? { row: 0, column: 0 }}
Expand Down Expand Up @@ -129,11 +129,7 @@ describe("Grid", () => {
const cell = queryByTestId("row-cell-0-0");
expect(cell).toBeDefined();

if (!cell) {
throw new Error("Cell with data-testid 'row-cell-0-0' not found");
}

const computedHeight = window.getComputedStyle(cell).height;
const computedHeight = window.getComputedStyle(cell!).height;
const heightValue = parseFloat(computedHeight);
expect(heightValue).toBe(33);
});
Expand All @@ -148,11 +144,7 @@ describe("Grid", () => {
const cell = queryByTestId("row-cell-0-0");
expect(cell).toBeDefined();

if (!cell) {
throw new Error("Cell with data-testid 'row-cell-0-0' not found");
}

const computedHeight = window.getComputedStyle(cell).height;
const computedHeight = window.getComputedStyle(cell!).height;
expect(computedHeight).toBe("100%");
});
});
2 changes: 1 addition & 1 deletion src/components/Grid/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export const Grid = forwardRef<HTMLDivElement, GridProps>(

const updateRowHeight = useCallback(
(rowIndex: number, height: number) => {
if (!rowAutoHeight) return;
if (!rowAutoHeight) {return;}
const prevHeight = rowHeightsRef.current.get(rowIndex) ?? 0;
if (height > prevHeight) {
rowHeightsRef.current.set(rowIndex, height);
Expand Down

0 comments on commit 6378cf8

Please sign in to comment.