mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-07-27 22:45:03 +00:00
fix(tags): fall back to row index in DataTable getRowId for idless rows
The shared DataTable is also used by the plan table, whose PlanWithTotals rows have no `id` (they carry planId/propertyId). A bare String(row.id) keyed every plan row as "undefined" — colliding React keys. Key by id when present, else by index (restoring the pre-change default for idless consumers). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
1d12fa1baf
commit
e80803c50a
1 changed files with 5 additions and 3 deletions
|
|
@ -82,9 +82,11 @@ export default function DataTable<TData extends Record<string, any>>({
|
|||
data,
|
||||
columns,
|
||||
|
||||
// Map selection/row identity to the property's stable id, so a selection
|
||||
// survives pagination and lazy-loaded pages (not row-index keyed).
|
||||
getRowId: (row) => String(row.id),
|
||||
// Key rows by their stable id when present (so a selection survives
|
||||
// pagination + lazy-loaded pages), falling back to the row index for
|
||||
// consumers whose rows have no `id` (e.g. the plan table) — otherwise every
|
||||
// idless row would collide on the key "undefined".
|
||||
getRowId: (row, index) => (row.id != null ? String(row.id) : String(index)),
|
||||
|
||||
getCoreRowModel: getCoreRowModel(),
|
||||
getSortedRowModel: getSortedRowModel(),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue