Repository navigation
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3967 +/- ##
=======================================
Coverage 98.35% 98.35%
=======================================
Files 45 45
Lines 1951 1951
Branches 727 727
=======================================
Hits 1919 1919
Misses 32 32
🚀 New features to boost your workflow:
|
| function groupRows( | ||
| rows: readonly R[], | ||
| [groupByKey, ...remainingGroupByKeys]: readonly string[], | ||
| groupByIndex: number, |
There was a problem hiding this comment.
Refactored this so we don't allocate temp arrays
| fn: Maybe<(...args: Args) => void> | ||
| ): Maybe<(...args: Args) => void>; | ||
|
|
||
| export function useLatestFunc<Args extends unknown[]>(fn: Maybe<(...args: Args) => void>) { |
There was a problem hiding this comment.
We can implement this without any/@ts-expect-error!
There was a problem hiding this comment.
Don't think I fully understand this TS code :)
There was a problem hiding this comment.
Me neither, it's some technical limitation of using unknown vs any I guess 🤷♂️
| Object.setPrototypeOf(cellEvent, Object.getPrototypeOf(event)); | ||
|
|
||
| return cellEvent; | ||
| }); |
There was a problem hiding this comment.
This creates a new object that inherits from the event object, and adds preventGridDefault/isGridDefaultPrevented property descriptors
WDYT?
| const columnWidth = getColumnWidth(column); | ||
| const colSpan = column.colSpan?.({ type: 'ROW', row: rows[rowIdx] }) ?? 1; | ||
| const { insetInlineStart, ...style } = getCellStyle(column, colSpan); | ||
| const style = getCellStyle(column, colSpan); |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
React does not mark state updates after an `await` as part of the transition, so `setRows` committed in a separate render from `isPending` turning false, briefly showing the loading message over the new rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The descriptions of the `*ContentProps` types and of the default content renderers still called them cell renderers, the term `RenderCellProps` now uses for `renderers.renderCell`. Call them cell content renderers, and name the column property each type is for. Also restore the sorted order of two type import lists that the `CellRendererProps` -> `RenderCellProps` rename had broken. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
They hold `format` functions now, not `Intl` formatter objects, so call them `formatDate` and `formatCurrency`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Stacked on #3967. Cell events inherit from React's event, but React's `stopPropagation()` and `preventDefault()` store their state on the object they're called on. When called on a cell event, they updated the cell event instead of React's event, so: - `stopPropagation()` in `onCellClick`, `onCellKeyDown`, or another cell event handler didn't stop React from calling parent handlers. - After `preventDefault()`, parent handlers saw `isDefaultPrevented()` return `false`. The native event was still updated, so the browser's default action was prevented. This predates #3967: cell events used to copy React's event, with the same result. Cell events now call these two methods on React's event. The two new tests failed in all three browsers before the fix. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
| fn: Maybe<(...args: Args) => void> | ||
| ): Maybe<(...args: Args) => void>; | ||
|
|
||
| export function useLatestFunc<Args extends unknown[]>(fn: Maybe<(...args: Args) => void>) { |
There was a problem hiding this comment.
Don't think I fully understand this TS code :)
| startTransition(async () => { | ||
| const newRows = await loadMoreRows(50, rows.length); | ||
| // state updates after `await` must be wrapped in another transition | ||
| startTransition(() => { |
There was a problem hiding this comment.
For my understand, does the isPending flag stay true until both transitions are complete?
There was a problem hiding this comment.
Yes.
The nested startTransition is necessary otherwise React wouldn't know that the nested state update is part of this transition.
https://react.dev/reference/react/useTransition#react-doesnt-treat-my-state-update-after-await-as-a-transition
I've renamed a few components/types for clarity and consistency.
It's like naming components
*Component.renderers.renderCellandcolumn.renderCell,I've changed some names from
*CellPropsto*CellContentPropsfor exampledefaultexports so we use the same named import everywhereBreaking changes:
RenderCellProps->RenderCellContentPropsRenderHeaderCellProps->RenderHeaderCellContentPropsRenderSummaryCellProps->RenderSummaryCellContentPropsRenderGroupCellProps->RenderGroupCellContentPropsRenderEditCellProps->RenderEditCellContentPropsCellRendererProps->RenderCellPropsRender*Propspattern), it'll conflict with the olderRenderCellPropstype name, need to be careful when updating RDGRenderCellPropshas a different shape and no default forTSummaryRow, so code still using the oldRenderCellPropsfails type checking instead of silently changing meaningSelectCellFormatter->SelectCheckboxRenderRowProps['activeCellEditor']is now typed with the props the editor cell actually receives, instead ofRenderEditCellPropsOther changes:
CellMouseEvent,CellKeyboardEvent) now inherit from the React event instead of copying its properties. As with React events,currentTargetisnullafter the handler returns.useLatestFuncis typed withoutanyor@ts-expect-errorTreeDataGridgroups rows without allocating temporary arrays*ContentPropstypes and the default content renderers are described as cell content renderers, androwGrouperandgroupIdGetterhave performance notesCellExpanderFormatter->CellExpander,DraggableRowRenderer->DraggableRow,FilterRenderer->FilterCell), and the infinite scrolling demo usesuseTransition