mirror of
https://github.com/grafana/grafana.git
synced 2024-11-25 10:20:29 -06:00
Fix tooltip not closing (#34001)
* Fix tooltip not closing * make this a bit less hacky * use a more specific element for the mouseleave event * Make sure we limit running of effect * Remove console log * Probably don't need useCallback
This commit is contained in:
parent
ca213ce9ad
commit
1b5f1bfe33
@ -47,6 +47,22 @@ export const TooltipPlugin: React.FC<TooltipPluginProps> = ({
|
||||
pluginLog(pluginId, true, `Focused series: ${focusedSeriesIdx}, focused point: ${focusedPointIdx}`);
|
||||
}, [focusedPointIdx, focusedSeriesIdx]);
|
||||
|
||||
useEffect(() => {
|
||||
const plotMouseLeave = () => {
|
||||
setCoords(null);
|
||||
};
|
||||
|
||||
if (plotCtx && plotCtx.plot) {
|
||||
plotCtx.plot.root.querySelector('.u-over')!.addEventListener('mouseleave', plotMouseLeave);
|
||||
}
|
||||
|
||||
return () => {
|
||||
if (plotCtx && plotCtx.plot) {
|
||||
plotCtx.plot.root.querySelector('.u-over')!.removeEventListener('mouseleave', plotMouseLeave);
|
||||
}
|
||||
};
|
||||
}, [plotCtx.plot?.root, setCoords]);
|
||||
|
||||
// Add uPlot hooks to the config, or re-add when the config changed
|
||||
useLayoutEffect(() => {
|
||||
if (config.tooltipInterpolator) {
|
||||
|
Loading…
Reference in New Issue
Block a user