Skip to content

Commit 973277c

Browse files
Fixes imports, rerenders, and overflow.
1 parent 8ffc18d commit 973277c

File tree

6 files changed

+5
-11
lines changed

6 files changed

+5
-11
lines changed

src/components/Grid/Cell.tsx

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

6161
useEffect(() => {
62-
if (rowCount !== 1) return;
62+
if (!rowAutoHeight) return;
6363
else if (cellRef.current) {
6464
const height = cellRef.current.getBoundingClientRect().height;
6565
updateRowHeight(rowIndex, height);
6666
}
67-
}, [rowCount, updateRowHeight, rowIndex]);
67+
}, [updateRowHeight, rowIndex, rowAutoHeight]);
6868

6969
const styleWithHeight = {
7070
...style,

src/components/Grid/Grid.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { CellProps, Grid, GridProps } from "@/components";
22
import { renderCUI } from "@/utils/test-utils";
33
import { SelectionFocus } from "./types";
44
import { ReactNode } from "react";
5-
import { act } from "react-dom/test-utils";
65

76
const Cell: CellProps = ({ type, rowIndex, columnIndex, isScrolling, ...props }) => {
87
let content = `${rowIndex} ${columnIndex} - ${type}`;

src/components/Grid/Grid.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,7 @@ export const Grid = forwardRef<HTMLDivElement, GridProps>(
227227

228228
const updateRowHeight = useCallback(
229229
(rowIndex: number, height: number) => {
230-
if (rowCount !== 1) return;
231-
230+
if (!rowAutoHeight) return;
232231
const prevHeight = rowHeightsRef.current.get(rowIndex) ?? 0;
233232
if (height > prevHeight) {
234233
rowHeightsRef.current.set(rowIndex, height);
@@ -237,7 +236,7 @@ export const Grid = forwardRef<HTMLDivElement, GridProps>(
237236
}
238237
}
239238
},
240-
[rowCount]
239+
[rowAutoHeight]
241240
);
242241

243242
const customOnCopy: () => Promise<void> = useMemo(() => {

src/components/Grid/Header.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ const Column = ({
153153
$isLastRow={false}
154154
$isFirstRow
155155
$height={height}
156-
$overflow="hidden"
157156
data-grid-row={-1}
158157
data-grid-column={columnIndex}
159158
data-selected={isSelected}

src/components/Grid/RowNumberColumn.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ const RowNumber = ({
103103
$isSelectedLeft={isSelected}
104104
$isSelectedTop={isSelectedTop}
105105
$rowAutoHeight={rowAutoHeight}
106-
$overflow="hidden"
107106
data-selected={isSelected}
108107
data-grid-row={currentRowIndex}
109108
data-grid-column={-1}

src/components/Grid/StyledCell.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export const StyledCell = styled.div<{
1414
$type?: "body" | "header";
1515
$showBorder: boolean;
1616
$rowAutoHeight?: boolean;
17-
$overflow?: string;
1817
}>`
1918
display: block;
2019
text-align: left;
@@ -37,11 +36,10 @@ export const StyledCell = styled.div<{
3736
$type = "body",
3837
$showBorder,
3938
$rowAutoHeight,
40-
$overflow,
4139
}) => `
4240
height: ${$rowAutoHeight ? "100%" : `${$height}px`};
4341
min-height: ${$rowAutoHeight ? "auto" : ""};
44-
overflow-y: ${$overflow ? $overflow : "auto"};
42+
overflow-y: ${$rowAutoHeight ? "auto" : ""};
4543
background: ${theme.click.grid[$type].cell.color.background[$selectionType]};
4644
color: ${
4745
$type === "header"

0 commit comments

Comments
 (0)