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
This commit is contained in:
Ashley Harrison 2021-07-06 10:48:10 +01:00 committed by GitHub
parent 2a4191a2ee
commit 96a3cc3cd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -135,6 +135,10 @@ export const TooltipPlugin: React.FC<TooltipPluginProps> = ({
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<TooltipPluginProps> = ({
const frame = otherProps.data;
const field = frame.fields[i];
if (
!field ||
field === xField ||
field.type === FieldType.time ||
field.type !== FieldType.number ||