[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 645776afc9)

Co-authored-by: Galen Kistler <109082771+gtk-grafana@users.noreply.github.com>
This commit is contained in:
grafana-delivery-bot[bot]
2024-12-09 13:02:20 -06:00
committed by GitHub
co-authored by Galen Kistler
parent 8a0b736610
commit 01a0baf5c1
@@ -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*/}