From 96a3cc3cd83baa9a739a9d7732754b3286608b5e Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Tue, 6 Jul 2021 10:48:10 +0100 Subject: [PATCH] TooltipPlugin: Prevent Tooltip render if field is undefined (#36260) * Tooltip Plugin: Prevent tooltip render if focusedSeriesIdx is out of range * TooltipPlugin: Also prevent render in multi case * TooltipPlugin: Return null if field is undefined --- .../src/components/uPlot/plugins/TooltipPlugin.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/grafana-ui/src/components/uPlot/plugins/TooltipPlugin.tsx b/packages/grafana-ui/src/components/uPlot/plugins/TooltipPlugin.tsx index 1c4a84785ca..2894002831b 100644 --- a/packages/grafana-ui/src/components/uPlot/plugins/TooltipPlugin.tsx +++ b/packages/grafana-ui/src/components/uPlot/plugins/TooltipPlugin.tsx @@ -135,6 +135,10 @@ export const TooltipPlugin: React.FC = ({ if (mode === TooltipDisplayMode.Single && focusedSeriesIdx !== null) { const field = otherProps.data.fields[focusedSeriesIdx]; + if (!field) { + return null; + } + const fieldFmt = field.display || getDisplayProcessor({ field, timeZone, theme }); const display = fieldFmt(field.values.get(focusedPointIdx)); @@ -160,6 +164,7 @@ export const TooltipPlugin: React.FC = ({ const frame = otherProps.data; const field = frame.fields[i]; if ( + !field || field === xField || field.type === FieldType.time || field.type !== FieldType.number ||