Skip to content

Commit 7f44ef1

Browse files
authored
Merge branch 'canary' into ts42
2 parents c517136 + d2ddc14 commit 7f44ef1

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

src/DataGrid.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ function DataGrid<R, SR>({
267267
expandedGroupIds
268268
});
269269

270-
const hasGroups = groupBy.length > 0 && rowGrouper;
270+
const hasGroups = groupBy.length > 0 && typeof rowGrouper === 'function';
271271
const minColIdx = hasGroups ? -1 : 0;
272272

273273
// Cell drag is not supported on a treegrid

src/GroupCell.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function GroupCell<R, SR>({
6262
}}
6363
onClick={isLevelMatching ? toggleGroup : undefined}
6464
>
65-
{column.groupFormatter && (!column.rowGroup || groupColumnIndex === column.idx) && (
65+
{(!column.rowGroup || groupColumnIndex === column.idx) && (
6666
<column.groupFormatter
6767
groupKey={groupKey}
6868
childRows={childRows}

src/hooks/useViewportColumns.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,23 @@ export function useViewportColumns<R, SR>({
3232
let lastFrozenColumnIndex = -1;
3333

3434
const columns = rawColumns.map(rawColumn => {
35-
const isGroup = rawGroupBy?.includes(rawColumn.key);
35+
const rowGroup = rawGroupBy?.includes(rawColumn.key) ?? false;
36+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
37+
const frozen = rowGroup || rawColumn.frozen || false;
3638

3739
const column: CalculatedColumn<R, SR> = {
3840
...rawColumn,
3941
idx: 0,
40-
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
41-
frozen: isGroup || rawColumn.frozen || false,
42+
frozen,
4243
isLastFrozenColumn: false,
43-
rowGroup: isGroup,
44+
rowGroup,
4445
sortable: rawColumn.sortable ?? defaultSortable,
4546
resizable: rawColumn.resizable ?? defaultResizable,
46-
formatter: rawColumn.formatter ?? defaultFormatter
47+
formatter: rawColumn.formatter ?? defaultFormatter,
48+
groupFormatter: rawColumn.groupFormatter ?? ToggleGroupFormatter
4749
};
4850

49-
if (column.frozen) {
51+
if (frozen) {
5052
lastFrozenColumnIndex++;
5153
}
5254

@@ -81,16 +83,15 @@ export function useViewportColumns<R, SR>({
8183
columns.forEach((column, idx) => {
8284
column.idx = idx;
8385

84-
if (idx === lastFrozenColumnIndex) {
85-
column.isLastFrozenColumn = true;
86-
}
87-
8886
if (column.rowGroup) {
8987
groupBy.push(column.key);
90-
column.groupFormatter ??= ToggleGroupFormatter;
9188
}
9289
});
9390

91+
if (lastFrozenColumnIndex !== -1) {
92+
columns[lastFrozenColumnIndex].isLastFrozenColumn = true;
93+
}
94+
9495
return {
9596
columns,
9697
lastFrozenColumnIndex,

src/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ export interface CalculatedColumn<TRow, TSummaryRow = unknown> extends Column<TR
6262
sortable: boolean;
6363
frozen: boolean;
6464
isLastFrozenColumn: boolean;
65-
rowGroup?: boolean;
65+
rowGroup: boolean;
6666
formatter: React.ComponentType<FormatterProps<TRow, TSummaryRow>>;
67+
groupFormatter: React.ComponentType<GroupFormatterProps<TRow, TSummaryRow>>;
6768
}
6869

6970
export interface ColumnMetric {

0 commit comments

Comments
 (0)