Skip to content

Commit 6378cf8

Browse files
Adds requested changes.
1 parent 6a77f93 commit 6378cf8

File tree

3 files changed

+9
-17
lines changed

3 files changed

+9
-17
lines changed

src/components/Grid/Cell.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ export const Cell = memo(
5959
const cellRef = useRef<HTMLDivElement>(null);
6060

6161
useEffect(() => {
62-
if (!rowAutoHeight) return;
63-
else if (cellRef.current) {
62+
if (!rowAutoHeight) {return;}
63+
if (cellRef.current) {
6464
const height = cellRef.current.getBoundingClientRect().height;
6565
updateRowHeight(rowIndex, height);
6666
}

src/components/Grid/Grid.test.tsx

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ describe("Grid", () => {
7171
};
7272

7373
const renderGrid = ({
74-
rowCount,
75-
columnCount,
74+
rowCount = 20,
75+
columnCount = 20,
7676
columnWidth,
7777
onColumnResize,
7878
focus,
@@ -82,8 +82,8 @@ describe("Grid", () => {
8282
}: Props) =>
8383
renderCUI(
8484
<Grid
85-
rowCount={rowCount ?? 20}
86-
columnCount={columnCount ?? 20}
85+
rowCount={rowCount}
86+
columnCount={columnCount}
8787
columnWidth={columnWidth ?? columnWidthTestFn}
8888
cell={Cell}
8989
focus={focus ?? { row: 0, column: 0 }}
@@ -129,11 +129,7 @@ describe("Grid", () => {
129129
const cell = queryByTestId("row-cell-0-0");
130130
expect(cell).toBeDefined();
131131

132-
if (!cell) {
133-
throw new Error("Cell with data-testid 'row-cell-0-0' not found");
134-
}
135-
136-
const computedHeight = window.getComputedStyle(cell).height;
132+
const computedHeight = window.getComputedStyle(cell!).height;
137133
const heightValue = parseFloat(computedHeight);
138134
expect(heightValue).toBe(33);
139135
});
@@ -148,11 +144,7 @@ describe("Grid", () => {
148144
const cell = queryByTestId("row-cell-0-0");
149145
expect(cell).toBeDefined();
150146

151-
if (!cell) {
152-
throw new Error("Cell with data-testid 'row-cell-0-0' not found");
153-
}
154-
155-
const computedHeight = window.getComputedStyle(cell).height;
147+
const computedHeight = window.getComputedStyle(cell!).height;
156148
expect(computedHeight).toBe("100%");
157149
});
158150
});

src/components/Grid/Grid.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ export const Grid = forwardRef<HTMLDivElement, GridProps>(
227227

228228
const updateRowHeight = useCallback(
229229
(rowIndex: number, height: number) => {
230-
if (!rowAutoHeight) return;
230+
if (!rowAutoHeight) {return;}
231231
const prevHeight = rowHeightsRef.current.get(rowIndex) ?? 0;
232232
if (height > prevHeight) {
233233
rowHeightsRef.current.set(rowIndex, height);

0 commit comments

Comments
 (0)