Skip to content

Commit

Permalink
tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
nstepien committed Aug 22, 2023
1 parent 880c6ef commit e54fcbe
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/DataGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ function DataGrid<R, SR, K extends Key>(
const direction = rawDirection ?? 'ltr';

/**
* computed values
* columns, counts, indexes
*/
const { columns, colSpanColumns, lastFrozenColumnIndex, headerRowsCount } = useCalculatedColumns(
rawColumns,
Expand All @@ -276,15 +276,6 @@ function DataGrid<R, SR, K extends Key>(
const minRowIdx = -headerAndTopSummaryRowsCount;
const mainHeaderIndex = minRowIdx + groupedColumnHeaderRowsCount;
const maxRowIdx = rows.length + bottomSummaryRowsCount - 1;
const isTreeGrid = role === 'treegrid';
const [gridRef, gridWidth, gridHeight] = useGridDimensions();
const clientHeight =
gridHeight - headerRowsCount * headerRowHeight - summaryRowsCount * summaryRowHeight;
const isSelectable = selectedRows != null && onSelectedRowsChange != null;
const isRtl = direction === 'rtl';
const leftKey = isRtl ? 'ArrowRight' : 'ArrowLeft';
const rightKey = isRtl ? 'ArrowLeft' : 'ArrowRight';
const ariaRowCount = rawAriaRowCount ?? headerRowsCount + rows.length + summaryRowsCount;

/**
* states
Expand Down Expand Up @@ -314,6 +305,19 @@ function DataGrid<R, SR, K extends Key>(
const focusSinkRef = useRef<HTMLDivElement>(null);
const shouldFocusCellRef = useRef(false);

/**
* computed values
*/
const isTreeGrid = role === 'treegrid';
const [gridRef, gridWidth, gridHeight] = useGridDimensions();
const clientHeight =
gridHeight - headerRowsCount * headerRowHeight - summaryRowsCount * summaryRowHeight;
const isSelectable = selectedRows != null && onSelectedRowsChange != null;
const isRtl = direction === 'rtl';
const leftKey = isRtl ? 'ArrowRight' : 'ArrowLeft';
const rightKey = isRtl ? 'ArrowLeft' : 'ArrowRight';
const ariaRowCount = rawAriaRowCount ?? headerRowsCount + rows.length + summaryRowsCount;

const defaultGridComponents = useMemo(
() => ({
renderCheckbox,
Expand Down

0 comments on commit e54fcbe

Please sign in to comment.