fix a click on the temporary anchor (#397)

Hovering a line in the routing tool shows a temporary anchor, which is
drawn in the anchors' layer with the index one past the last anchor.
Clicking it reached onClick, which looked that index up in the anchors,
got undefined and threw reading its properties. The click now adds the
anchor, as a click on the line does.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: vcoppe <vianney.coppe@gmail.com>
This commit is contained in:
authored and GitHub committed 2026-11-08 14:26:58 +01:00
1 parent 2608870505
commit b80fa7d942
1 file changed
+5
@@ -633,6 +633,11 @@ export class RoutingControls {
const anchor = this.anchors[e.features![0].properties.anchorIndex]; const anchor = this.anchors[e.features![0].properties.anchorIndex];
if (!anchor) { if (!anchor) {
// The temporary anchor on the line is not one of the anchors (nor is a feature
// still rendered from before they were rebuilt), a click on it adds it
if (e.type === 'click') {
this.addIntermediateAnchor(e);
}
return; return;
} }
if (e.originalEvent.shiftKey) { if (e.originalEvent.shiftKey) {