From 01a0baf5c132d5b575951982b969247cb7ce88c1 Mon Sep 17 00:00:00 2001 From: "grafana-delivery-bot[bot]" <132647405+grafana-delivery-bot[bot]@users.noreply.github.com> Date: Mon, 9 Dec 2024 13:02:20 -0600 Subject: [PATCH] [v11.4.x] Table: RowsList passing incorrect index to onRowHover (#97678) Table: RowsList passing incorrect index to onRowHover (#97599) * chore: fix table returning the wrong index to onRowHover (cherry picked from commit 645776afc9117ad5a2ba719d54db48b8d4140bfe) Co-authored-by: Galen Kistler <109082771+gtk-grafana@users.noreply.github.com> --- 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 977af857af4..d4edf8d1828 100644 --- a/packages/grafana-ui/src/components/Table/RowsList.tsx +++ b/packages/grafana-ui/src/components/Table/RowsList.tsx @@ -119,12 +119,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: { @@ -305,7 +309,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*/}