Repository navigation
TreeDataGrid: type group keys and IDs as strings, and export GroupRow - #4263
Merged
Merged
Conversation
`getRowGroupKey` and `getGroupId` return strings, so `expandedGroupIds`, `onExpandedGroupIdsChange`, `GroupRow.groupKey`, `GroupRow.parentId`, and `RenderGroupCellContentProps.groupKey` are now typed with `string` instead of `unknown`. `GroupRow` is exported and its members are documented. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GroupRow
GroupRowTreeDataGrid: type group keys and IDs as strings, and export GroupRow
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4263 +/- ##
=======================================
Coverage 99.27% 99.27%
=======================================
Files 44 44
Lines 2216 2216
Branches 974 974
=======================================
Hits 2200 2200
Misses 16 16
🚀 New features to boost your workflow:
|
nstepien
marked this pull request as ready for review
October 28, 2026 11:02
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Its assertions restated the declarations. `setup()` and the row grouping demo already pass `ReadonlySet<string>` state and its setter to the grid, `toggleGroup` passes `new Set(expandedGroupIds)` to `onExpandedGroupIdsChange`, and `renderToggleGroup` renders `groupKey` without a cast. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nstepien
added a commit
that referenced
this pull request
Oct 29, 2026
`RenderGroupCellContentProps` had `groupKey`, `childRows`, and
`isExpanded` next to `row`, a `GroupRow` that carries the same three
properties. The duplication dates from when `GroupRow` couldn't be named
outside the package; now that it's exported, the props are `{ column,
row, tabIndex, toggleGroup }`, which leaves one shape to document and a
smaller object per group cell.
Builds on #4263, which exports `GroupRow` and types its keys as strings.
### Breaking change
```diff
- renderGroupCell({ childRows }) {
- return childRows.reduce((sum, row) => sum + row.gold, 0);
+ renderGroupCell({ row }) {
+ return row.childRows.reduce((sum, childRow) => sum + childRow.gold, 0);
}
```
`groupKey`, `childRows`, and `isExpanded` are removed from
`RenderGroupCellContentProps`; read them from `row`, which is a
`GroupRow`.
### Changes
- `GroupCell`'s own props are slimmed to `{ column, row, isCellActive,
isGroupByColumn, isLevelMatching, toggleGroup }`, and it reads `row.id`
for the toggle. `row` was already one of its props, so its memoization
invalidates exactly as before.
- `ToggleGroup` reads `row.groupKey` and `row.isExpanded`.
- The row grouping demo, `TreeDataGrid.test.tsx`, and
`test/visual/treeGrid.test.tsx` (type-checked only) read
`row.childRows`.
- README: the `RenderGroupCellContentProps` block matches the new JSDoc,
`renderGroupCell` gets an example, and `renderToggleGroup` says it
renders `row.groupKey`.
### Verification
Static checks (`vp check`, `vp run typecheck`, `vp run eslint`) and `vp
pack` pass, and `TreeDataGrid.test.tsx` and `columnOrder.test.tsx` pass
in Chromium, Firefox, and WebKit. The `custom renderGroupCell` test
covers the `row.childRows` path. No type test is added, because
`ToggleGroup`, the row grouping demo, and that test already read the
group from `row`. `vp run ci` passes on the top of the stack (#4272).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since #4159,
getRowGroupKeyandgetGroupIdreturn strings, soTreeDataGridonly ever produces string group keys and IDs, but the types still saidunknown. Apps had to castgroupKey as string, or keepexpandedGroupIdsin aReadonlySet<unknown>that could hold values the grid never produces. This types them all asstring, and exportsGroupRow, which already appeared in public types (RenderGroupCellContentProps.row,RowHeightArgs) but couldn't be named.This is the first PR of a stack of four: #4264 builds on it, and #4272 renames
GroupRowtoRowGroup.Breaking change
expandedGroupIds,onExpandedGroupIdsChange,GroupRow.groupKey,GroupRow.parentId, andRenderGroupCellContentProps.groupKeyare typed withstringinstead ofunknown, which is whatgetRowGroupKeyandgetGroupIdproduce.GroupRowis now exported.Changes
GroupRow.parentIdisstring | undefined(undefinedon the first level) andGroupRow.groupKeyisstring; everyGroupRowmember now has JSDoc, checked againstexpandGroupsandsetStartRowIndexes.RenderGroupCellContentProps.groupKeyisstring;RenderGroupCellContentProps: pass the group row only #4264 then removes it in favor ofrow.groupKey.toggleGroupparameters ofTreeDataGrid,GroupedRow, andGroupCellarestring, andrenderToggleGroupno longer castsgroupKey as string.GroupRowis exported fromsrc/index.ts; its README entry is no longer "(internal)" and sits next toRenderGroupCellContentProps, and theRenderGroupCellContentPropsandRowHeightArgsentries link to it.ReadonlySet<unknown>state in the row grouping demo and inTreeDataGrid.test.tsxis nowReadonlySet<string>. Thenew Set()literals passed toexpandedGroupIdsinferSet<string>and need no change.Verification
vp run cipasses. No tests are added, because the existing code already type-checks the new types:setup()inTreeDataGrid.test.tsxand the row grouping demo passReadonlySet<string>state and its setter to the grid,toggleGrouppassesnew Set(expandedGroupIds)toonExpandedGroupIdsChange, andrenderToggleGrouprendersgroupKeywithout a cast. A consumer type-check of the builtlib/index.d.ts, with and withoutexactOptionalPropertyTypes, confirms thatReadonlySet<unknown>state is a type error atexpandedGroupIdsand thatReadonlySet<string>state accepts theSet<string>fromonExpandedGroupIdsChange.🤖 Generated with Claude Code