diff --git a/packages/core/src/data-editor/row-grouping-api.ts b/packages/core/src/data-editor/row-grouping-api.ts index 23eeb8803..988de9013 100644 --- a/packages/core/src/data-editor/row-grouping-api.ts +++ b/packages/core/src/data-editor/row-grouping-api.ts @@ -1,13 +1,13 @@ import React from "react"; import type { Item } from "../internal/data-grid/data-grid-types.js"; -import { flattenRowGroups, mapRowIndexToPath, type RowGroup, type RowGroupingOptions } from "./row-grouping.js"; +import { flattenRowGroups, mapRowIndexToPath, type RowGroup, type RowGroupingOptions, type MapResult } from "./row-grouping.js"; -export type RowGroupingMapperResult = { +export interface RowGroupingMapperResult extends Omit { path: readonly number[]; originalIndex: T; isGroupHeader: boolean; groupRows: number; -}; +} export type RowGroupingMapper = { (itemOrRow: number): RowGroupingMapperResult; diff --git a/packages/core/src/data-editor/row-grouping.ts b/packages/core/src/data-editor/row-grouping.ts index c3651d16f..4cda4782b 100644 --- a/packages/core/src/data-editor/row-grouping.ts +++ b/packages/core/src/data-editor/row-grouping.ts @@ -167,7 +167,7 @@ export function flattenRowGroups(rowGrouping: RowGroupingOptions, rows: number): }); } -interface MapResult { +export interface MapResult { readonly path: readonly number[]; readonly isGroupHeader: boolean; readonly originalIndex: number; @@ -202,11 +202,11 @@ export function mapRowIndexToPath(row: number, flattenedRowGroups?: readonly Fla if (!group.isCollapsed) { if (toGo <= group.rows) return { - path: [...group.path, toGo], + path: [...group.path, toGo - 1], originalIndex: group.headerIndex + toGo, isGroupHeader: false, - groupIndex: toGo, - contentIndex: group.contentIndex + toGo, + groupIndex: toGo - 1, + contentIndex: group.contentIndex + toGo - 1, groupRows: group.rows, }; toGo = toGo - group.rows - 1;