Skip to content

Commit 7cb8c1a

Browse files
Sassoun Derderianv-genn
authored andcommitted
fix: contentIndex, path, groupIndex values, and mapper types
1 parent 201807b commit 7cb8c1a

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

packages/core/src/data-editor/row-grouping-api.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import React from "react";
22
import type { Item } from "../internal/data-grid/data-grid-types.js";
3-
import { flattenRowGroups, mapRowIndexToPath, type RowGroup, type RowGroupingOptions } from "./row-grouping.js";
3+
import { flattenRowGroups, mapRowIndexToPath, type RowGroup, type RowGroupingOptions, type MapResult } from "./row-grouping.js";
44

5-
export type RowGroupingMapperResult<T> = {
5+
export interface RowGroupingMapperResult<T> extends Omit<MapResult, 'originalIndex'> {
66
path: readonly number[];
77
originalIndex: T;
88
isGroupHeader: boolean;
99
groupRows: number;
10-
};
10+
}
1111

1212
export type RowGroupingMapper = {
1313
(itemOrRow: number): RowGroupingMapperResult<number>;

packages/core/src/data-editor/row-grouping.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export function flattenRowGroups(rowGrouping: RowGroupingOptions, rows: number):
167167
});
168168
}
169169

170-
interface MapResult {
170+
export interface MapResult {
171171
readonly path: readonly number[];
172172
readonly isGroupHeader: boolean;
173173
readonly originalIndex: number;
@@ -202,11 +202,11 @@ export function mapRowIndexToPath(row: number, flattenedRowGroups?: readonly Fla
202202
if (!group.isCollapsed) {
203203
if (toGo <= group.rows)
204204
return {
205-
path: [...group.path, toGo],
205+
path: [...group.path, toGo - 1],
206206
originalIndex: group.headerIndex + toGo,
207207
isGroupHeader: false,
208-
groupIndex: toGo,
209-
contentIndex: group.contentIndex + toGo,
208+
groupIndex: toGo - 1,
209+
contentIndex: group.contentIndex + toGo - 1,
210210
groupRows: group.rows,
211211
};
212212
toGo = toGo - group.rows - 1;

0 commit comments

Comments
 (0)