From cc843e67ae609a49cb440e83a17afe1162eac621 Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Tue, 6 Jul 2021 12:19:40 +0200 Subject: [PATCH] TooltipPlugin: Prevent Tooltip render if field is undefined (#36260) (#36464) * 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 (cherry picked from commit 96a3cc3cd83baa9a739a9d7732754b3286608b5e) Co-authored-by: Ashley Harrison --- .../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 ||