From 645776afc9117ad5a2ba719d54db48b8d4140bfe Mon Sep 17 00:00:00 2001 From: Galen Kistler <109082771+gtk-grafana@users.noreply.github.com> Date: Mon, 9 Dec 2024 10:23:44 -0600 Subject: [PATCH] Table: RowsList passing incorrect index to onRowHover (#97599) * chore: fix table returning the wrong index to onRowHover --- packages/grafana-ui/src/components/Table/RowsList.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/grafana-ui/src/components/Table/RowsList.tsx b/packages/grafana-ui/src/components/Table/RowsList.tsx index 76ffe7770d4..646b4781fbe 100644 --- a/packages/grafana-ui/src/components/Table/RowsList.tsx +++ b/packages/grafana-ui/src/components/Table/RowsList.tsx @@ -124,12 +124,16 @@ export const RowsList = (props: RowsListProps) => { const onRowHover = useCallback( (idx: number, frame: DataFrame) => { - if (!panelContext || !enableSharedCrosshair || !hasTimeField(frame)) { + if (!panelContext || !enableSharedCrosshair) { return; } const timeField: Field = frame!.fields.find((f) => f.type === FieldType.time)!; + if (!timeField) { + return; + } + panelContext.eventBus.publish( new DataHoverEvent({ point: { @@ -311,7 +315,7 @@ export const RowsList = (props: RowsListProps) => { key={key} {...rowProps} className={cx(tableStyles.row, expandedRowStyle)} - onMouseEnter={() => onRowHover(index, data)} + onMouseEnter={() => onRowHover(row.index, data)} onMouseLeave={onRowLeave} > {/*add the nested data to the DOM first to prevent a 1px border CSS issue on the last cell of the row*/}