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:
Khalim Conn-Kowlessar 2026-07-13 19:16:51 +00:00
parent 1d12fa1baf
commit e80803c50a

View file

@ -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(),