Skip to content

Commit a19002c

Browse files
committed
Populate the elevation readout when the toggle is switched on
The effect cleared the readout when the toggle went off while the pointer was stationary, but the symmetric case was unhandled: switching it on with the cursor still showed nothing until the next mousemove. It now resolves once for wherever the pointer already is.
1 parent 213097c commit a19002c

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

packages/map/src/MapCanvas.tsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,13 +1085,20 @@ export const MapCanvas = memo(function MapCanvas({
10851085
// map (a keyboard-only toggle) would otherwise leave the last resolved value
10861086
// on screen until the next mousemove.
10871087
useEffect(() => {
1088-
if (showPointerElevation) return;
1089-
// invalidate() before clearing: a lookup scheduled inside the 500ms debounce
1090-
// window would otherwise still fire the request, and only be suppressed
1091-
// afterwards by the isEnabled() re-check. Cancelling the timer means the
1092-
// request is never made at all.
1093-
pointerElevationRef.current?.invalidate();
1094-
setPointerElevation(null);
1088+
if (!showPointerElevation) {
1089+
// invalidate() before clearing: a lookup scheduled inside the 500ms
1090+
// debounce window would otherwise still fire the request, and only be
1091+
// suppressed afterwards by the isEnabled() re-check. Cancelling the timer
1092+
// means the request is never made at all.
1093+
pointerElevationRef.current?.invalidate();
1094+
setPointerElevation(null);
1095+
return;
1096+
}
1097+
// Symmetrically, switching it *on* while the cursor sits still would show
1098+
// nothing until the next mousemove. Resolve once for wherever the pointer
1099+
// already is, so the readout appears with the toggle.
1100+
const coords = useAppStore.getState().pointerCoords;
1101+
if (coords) pointerElevationRef.current?.update(coords);
10951102
}, [showPointerElevation, setPointerElevation]);
10961103
const previousSelectedFeatureKey = useRef<string | null>(null);
10971104
const previousDuckDBSelectionLayerId = useRef<string | null>(null);

0 commit comments

Comments
 (0)