From cab241fbb6327273f9ca0307fc4150989c1b34ee Mon Sep 17 00:00:00 2001 From: Alex Spencer <52186778+alexjonspencer1@users.noreply.github.com> Date: Mon, 5 May 2025 13:16:05 -0600 Subject: [PATCH] TableNG: Always use correct original row index (#104561) * fix: change row index * chore: remove unused param --- .../grafana-ui/src/components/Table/TableNG/TableNG.tsx | 7 ++----- packages/grafana-ui/src/components/Table/TableNG/utils.ts | 1 - 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/grafana-ui/src/components/Table/TableNG/TableNG.tsx b/packages/grafana-ui/src/components/Table/TableNG/TableNG.tsx index 823da839800..b80cb003160 100644 --- a/packages/grafana-ui/src/components/Table/TableNG/TableNG.tsx +++ b/packages/grafana-ui/src/components/Table/TableNG/TableNG.tsx @@ -451,8 +451,6 @@ export function TableNG(props: TableNGProps) { ctx, onSortByChange, rows, - // INFO: sortedRows is for correct row indexing for cell background coloring - sortedRows, setContextMenuProps, setFilter, setIsInspecting, @@ -662,7 +660,6 @@ export function mapFrameToDataGrid({ ctx, onSortByChange, rows, - sortedRows, setContextMenuProps, setFilter, setIsInspecting, @@ -787,7 +784,7 @@ export function mapFrameToDataGrid({ field, cellClass: textWraps[getDisplayName(field)] ? styles.cellWrapped : styles.cell, renderCell: (props: RenderCellProps): JSX.Element => { - const { row, rowIdx } = props; + const { row } = props; const cellType = field.config?.custom?.cellOptions?.type ?? TableCellDisplayMode.Auto; const value = row[key]; // Cell level rendering here @@ -801,7 +798,7 @@ export function mapFrameToDataGrid({ timeRange={timeRange ?? getDefaultTimeRange()} height={defaultRowHeight} justifyContent={justifyColumnContent} - rowIdx={sortedRows[rowIdx].__index} + rowIdx={row.__index} shouldTextOverflow={() => shouldTextOverflow( key, diff --git a/packages/grafana-ui/src/components/Table/TableNG/utils.ts b/packages/grafana-ui/src/components/Table/TableNG/utils.ts index 58a5767defa..86fe496fb41 100644 --- a/packages/grafana-ui/src/components/Table/TableNG/utils.ts +++ b/packages/grafana-ui/src/components/Table/TableNG/utils.ts @@ -502,7 +502,6 @@ export interface MapFrameToGridOptions extends TableNGProps { ctx: CanvasRenderingContext2D; onSortByChange?: (sortBy: TableSortByFieldState[]) => void; rows: TableRow[]; - sortedRows: TableRow[]; setContextMenuProps: (props: { value: string; top?: number; left?: number; mode?: TableCellInspectorMode }) => void; setFilter: React.Dispatch>; setIsInspecting: (isInspecting: boolean) => void;