Skip to content

Commit 6fd5cc1

Browse files
committed
fix(elevation): drop the remembered hover when a new line is profiled
The flicker fix remembers the hovered sample index so a redraw can restore the crosshair. A new profile is also a redraw, so loading a different line (e.g. "Use selected", which does not go through _clearProfile) would paint a crosshair and readout at the old index even though the pointer is on a button, not the chart. Clear the hover when _profileLine installs a new line.
1 parent f42e0ea commit 6fd5cc1

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

packages/plugins/src/plugins/elevation-profile/core/ElevationProfileControl.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,10 @@ export class ElevationProfileControl implements IControl, DeepLinkConsumer {
405405
embeddedElevations: number[] | null = null,
406406
): Promise<void> {
407407
if (!this._map) return;
408+
// A different line means the remembered hover index no longer refers to
409+
// anything the pointer is on, so drop it before the new chart is drawn (a
410+
// redraw restores the marker for whatever index is still set).
411+
this._clearHover();
408412
this._state.line = coords.map((c) => [...c] as LngLat);
409413
this._state.elevations =
410414
embeddedElevations?.length === coords.length ? [...embeddedElevations] : null;

0 commit comments

Comments
 (0)