Skip to content

Commit

Permalink
fix(data-table): key by row id, not data
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusandra committed Dec 19, 2023
1 parent 45a0600 commit e2cceca
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions frontend/src/queries/nodes/DataTable/DataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -474,26 +474,7 @@ export function DataTable({ uniqueKey, query, setQuery, context, cachedResults }
) /* Bust the LemonTable cache when columns change */
}
dataSource={dataTableRows ?? []}
rowKey={({ result }: DataTableRow, rowIndex) => {
if (result) {
if (
sourceFeatures.has(QueryFeature.resultIsArrayOfArrays) &&
sourceFeatures.has(QueryFeature.columnsInResponse)
) {
if (columnsInResponse?.includes('*')) {
return result[columnsInResponse.indexOf('*')].uuid
} else if (columnsInResponse?.includes('uuid')) {
return result[columnsInResponse.indexOf('uuid')]
} else if (columnsInResponse?.includes('id')) {
return result[columnsInResponse.indexOf('id')]
}
}
return (
(result && 'uuid' in result ? (result as any).uuid : null) ??
(result && 'id' in result ? (result as any).id : null) ??
rowIndex
)
}
rowKey={(_, rowIndex) => {
return rowIndex
}}
sorting={null}
Expand Down

0 comments on commit e2cceca

Please sign in to comment.