From a257b74d6eb333be6aad49ccc0cc988f0a74d5f8 Mon Sep 17 00:00:00 2001 From: Leon Sorokin Date: Fri, 31 May 2024 13:17:54 -0500 Subject: [PATCH] TooltipPlugin: Fix console error when data updates while anchored (#88546) --- .../src/components/uPlot/plugins/TooltipPlugin2.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/grafana-ui/src/components/uPlot/plugins/TooltipPlugin2.tsx b/packages/grafana-ui/src/components/uPlot/plugins/TooltipPlugin2.tsx index 7a84afcfbd9..095ccdca520 100644 --- a/packages/grafana-ui/src/components/uPlot/plugins/TooltipPlugin2.tsx +++ b/packages/grafana-ui/src/components/uPlot/plugins/TooltipPlugin2.tsx @@ -404,6 +404,7 @@ export const TooltipPlugin2 = ({ config.addHook('setData', (u) => { yZoomed = false; yDrag = false; + dismiss(); }); // fires on series focus/proximity changes @@ -526,6 +527,10 @@ export const TooltipPlugin2 = ({ return () => { window.removeEventListener('resize', updateWinSize); window.removeEventListener('scroll', onscroll, true); + + // in case this component unmounts while anchored (due to data auto-refresh + re-config) + document.removeEventListener('mousedown', downEventOutside, true); + document.removeEventListener('keydown', downEventOutside, true); }; }, [config]);