Skip to content

Commit

Permalink
Fixes imports, rerenders, and overflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
natalyjazzviolin committed Feb 10, 2025
1 parent 8ffc18d commit 973277c
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 11 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,12 +59,12 @@ export const Cell = memo(
const cellRef = useRef<HTMLDivElement>(null);

useEffect(() => {
if (rowCount !== 1) return;
if (!rowAutoHeight) return;
else if (cellRef.current) {
const height = cellRef.current.getBoundingClientRect().height;
updateRowHeight(rowIndex, height);
}
}, [rowCount, updateRowHeight, rowIndex]);
}, [updateRowHeight, rowIndex, rowAutoHeight]);

const styleWithHeight = {
...style,
Expand Down
1 change: 0 additions & 1 deletion src/components/Grid/Grid.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { CellProps, Grid, GridProps } from "@/components";
import { renderCUI } from "@/utils/test-utils";
import { SelectionFocus } from "./types";
import { ReactNode } from "react";
import { act } from "react-dom/test-utils";

const Cell: CellProps = ({ type, rowIndex, columnIndex, isScrolling, ...props }) => {
let content = `${rowIndex} ${columnIndex} - ${type}`;
Expand Down
5 changes: 2 additions & 3 deletions src/components/Grid/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,7 @@ export const Grid = forwardRef<HTMLDivElement, GridProps>(

const updateRowHeight = useCallback(
(rowIndex: number, height: number) => {
if (rowCount !== 1) return;

if (!rowAutoHeight) return;
const prevHeight = rowHeightsRef.current.get(rowIndex) ?? 0;
if (height > prevHeight) {
rowHeightsRef.current.set(rowIndex, height);
Expand All @@ -237,7 +236,7 @@ export const Grid = forwardRef<HTMLDivElement, GridProps>(
}
}
},
[rowCount]
[rowAutoHeight]
);

const customOnCopy: () => Promise<void> = useMemo(() => {
Expand Down
1 change: 0 additions & 1 deletion src/components/Grid/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ const Column = ({
$isLastRow={false}
$isFirstRow
$height={height}
$overflow="hidden"
data-grid-row={-1}
data-grid-column={columnIndex}
data-selected={isSelected}
Expand Down
1 change: 0 additions & 1 deletion src/components/Grid/RowNumberColumn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ const RowNumber = ({
$isSelectedLeft={isSelected}
$isSelectedTop={isSelectedTop}
$rowAutoHeight={rowAutoHeight}
$overflow="hidden"
data-selected={isSelected}
data-grid-row={currentRowIndex}
data-grid-column={-1}
Expand Down
4 changes: 1 addition & 3 deletions src/components/Grid/StyledCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export const StyledCell = styled.div<{
$type?: "body" | "header";
$showBorder: boolean;
$rowAutoHeight?: boolean;
$overflow?: string;
}>`
display: block;
text-align: left;
Expand All @@ -37,11 +36,10 @@ export const StyledCell = styled.div<{
$type = "body",
$showBorder,
$rowAutoHeight,
$overflow,
}) => `
height: ${$rowAutoHeight ? "100%" : `${$height}px`};
min-height: ${$rowAutoHeight ? "auto" : ""};
overflow-y: ${$overflow ? $overflow : "auto"};
overflow-y: ${$rowAutoHeight ? "auto" : ""};
background: ${theme.click.grid[$type].cell.color.background[$selectionType]};
color: ${
$type === "header"
Expand Down

0 comments on commit 973277c

Please sign in to comment.