From 467c42f15b15e8c53fffd3e4cf78c74b08341342 Mon Sep 17 00:00:00 2001 From: Sassoun Derderian Date: Fri, 13 Sep 2024 11:02:08 +0400 Subject: [PATCH] fix: row grouping algorithm fixes https://github.com/glideapps/glide-data-grid/issues/823#issuecomment-2178674929 4th point --- packages/core/src/data-editor/row-grouping.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/core/src/data-editor/row-grouping.ts b/packages/core/src/data-editor/row-grouping.ts index 4f90c86ec..c3651d16f 100644 --- a/packages/core/src/data-editor/row-grouping.ts +++ b/packages/core/src/data-editor/row-grouping.ts @@ -199,9 +199,8 @@ export function mapRowIndexToPath(row: number, flattenedRowGroups?: readonly Fla contentIndex: -1, groupRows: group.rows, }; - toGo--; if (!group.isCollapsed) { - if (toGo < group.rows) + if (toGo <= group.rows) return { path: [...group.path, toGo], originalIndex: group.headerIndex + toGo, @@ -210,7 +209,9 @@ export function mapRowIndexToPath(row: number, flattenedRowGroups?: readonly Fla contentIndex: group.contentIndex + toGo, groupRows: group.rows, }; - toGo -= group.rows; + toGo = toGo - group.rows - 1; + } else { + toGo--; } } // this shouldn't happen