From 16e5d442ba1c7ca410f41f0e399efe83d6476d3e Mon Sep 17 00:00:00 2001 From: Nathan Marrs Date: Fri, 14 Jul 2023 05:21:06 +0200 Subject: [PATCH] Geomap: Address tooltip performance issue (#71607) --- .betterer.results | 2 +- public/app/plugins/panel/geomap/GeomapPanel.tsx | 2 +- .../app/plugins/panel/geomap/utils/{tootltip.ts => tooltip.ts} | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) rename public/app/plugins/panel/geomap/utils/{tootltip.ts => tooltip.ts} (97%) diff --git a/.betterer.results b/.betterer.results index 2638b8fecaf..7922ba7b01a 100644 --- a/.betterer.results +++ b/.betterer.results @@ -4881,7 +4881,7 @@ exports[`better eslint`] = { "public/app/plugins/panel/geomap/utils/selection.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/plugins/panel/geomap/utils/tootltip.ts:5381": [ + "public/app/plugins/panel/geomap/utils/tooltip.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], "public/app/plugins/panel/graph/GraphContextMenuCtrl.ts:5381": [ diff --git a/public/app/plugins/panel/geomap/GeomapPanel.tsx b/public/app/plugins/panel/geomap/GeomapPanel.tsx index ff2bdd7cced..f9cdad583d3 100644 --- a/public/app/plugins/panel/geomap/GeomapPanel.tsx +++ b/public/app/plugins/panel/geomap/GeomapPanel.tsx @@ -29,7 +29,7 @@ import { ControlsOptions, Options, MapLayerState, MapViewConfig, TooltipMode } f import { getActions } from './utils/actions'; import { getLayersExtent } from './utils/getLayersExtent'; import { applyLayerFilter, initLayer } from './utils/layers'; -import { pointerClickListener, pointerMoveListener, setTooltipListeners } from './utils/tootltip'; +import { pointerClickListener, pointerMoveListener, setTooltipListeners } from './utils/tooltip'; import { updateMap, getNewOpenLayersMap, notifyPanelEditor } from './utils/utils'; import { centerPointRegistry, MapCenterID } from './view'; diff --git a/public/app/plugins/panel/geomap/utils/tootltip.ts b/public/app/plugins/panel/geomap/utils/tooltip.ts similarity index 97% rename from public/app/plugins/panel/geomap/utils/tootltip.ts rename to public/app/plugins/panel/geomap/utils/tooltip.ts index 1d5c601e823..aeb3722a008 100644 --- a/public/app/plugins/panel/geomap/utils/tootltip.ts +++ b/public/app/plugins/panel/geomap/utils/tooltip.ts @@ -1,3 +1,4 @@ +import { debounce } from 'lodash'; import { MapBrowserEvent } from 'ol'; import { toLonLat } from 'ol/proj'; @@ -12,7 +13,7 @@ import { getMapLayerState } from './layers'; export const setTooltipListeners = (panel: GeomapPanel) => { // Tooltip listener panel.map?.on('singleclick', panel.pointerClickListener); - panel.map?.on('pointermove', panel.pointerMoveListener); + panel.map?.on('pointermove', debounce(panel.pointerMoveListener, 200)); panel.map?.getViewport().addEventListener('mouseout', (evt: MouseEvent) => { panel.props.eventBus.publish(new DataHoverClearEvent()); });