Route editor: one click on the route line inserts two anchors at the same spot (0 m leg) #69

Closed
opened 2026-11-05 19:19:00 +00:00 by maximus · 1 comment
Member

Found in the live acceptance test of deploy-676a7c62 (2026-11-05), user claude_test (#49: "dragging and clicking the coloured line still edits the route").

Problem: in drawing mode with the default "Shortest-path insertion", one click on the route line inserts two anchors at the same spot. That leaves a 0 m leg ("Route Point #2 … 0 m"). Dragging the line works correctly (+1 anchor, re-routed).

Why: both handlers fire for the same click:

  • map_with_elevation_maplibre handleDragStart → handleDragEnd, distance < 0.5 → onsegmentclick → handleSegmentClick: addAnchor + splitSegment, no routing call;
  • the map click → handleMapClick (drawing branch) → addAnchorSmart → insertAnchorShortest: a second addAnchor plus 2 routing calls.

Nothing in handleMapClick skips clicks that landed on the route layer. The colour overlay from #49 is not the cause; the base layer gets the same events.

Repro (1440 px, Sospel, zoom 13):

  1. Open /trail/edit/new and draw 3 points (start, A, finish).
  2. Click once exactly on the middle of the first leg's line.
  3. Expected: 4 anchors. Actual: 5 anchors. "Route Point #1" and "Route Point #2" have the same coordinates (43.8783, 7.4527), and #2's leg is "0 m".

Evidence: /root/tools/wanderer-shots/acceptance/out/t3g-click-on-coloured-line.png. Script: /root/tools/wanderer-shots/acceptance/t3_editor.mjs (step 3f: anchors 3 → 5, 2 routing calls).

Fix idea: when handleDragStart has claimed the mousedown (it already calls e.preventDefault()), let handleMapClick return early, for example by checking e.defaultPrevented or a "segment click handled" flag. Alternatively, drop one of the two paths.

🤖 Generated with Claude Code

Found in the live acceptance test of `deploy-676a7c62` (2026-11-05), user `claude_test` (#49: "dragging and clicking the coloured line still edits the route"). **Problem:** in drawing mode with the default "Shortest-path insertion", **one click on the route line inserts two anchors at the same spot**. That leaves a 0 m leg ("Route Point #2 … 0 m"). Dragging the line works correctly (+1 anchor, re-routed). **Why:** both handlers fire for the same click: - `map_with_elevation_maplibre` `handleDragStart` → `handleDragEnd`, distance < 0.5 → `onsegmentclick` → `handleSegmentClick`: `addAnchor` + `splitSegment`, no routing call; - the map `click` → `handleMapClick` (drawing branch) → `addAnchorSmart` → `insertAnchorShortest`: a second `addAnchor` plus 2 routing calls. Nothing in `handleMapClick` skips clicks that landed on the route layer. The colour overlay from #49 is not the cause; the base layer gets the same events. **Repro (1440 px, Sospel, zoom 13):** 1. Open `/trail/edit/new` and draw 3 points (start, A, finish). 2. Click once exactly on the middle of the first leg's line. 3. **Expected:** 4 anchors. **Actual:** 5 anchors. "Route Point #1" and "Route Point #2" have the same coordinates (43.8783, 7.4527), and #2's leg is "0 m". **Evidence:** `/root/tools/wanderer-shots/acceptance/out/t3g-click-on-coloured-line.png`. Script: `/root/tools/wanderer-shots/acceptance/t3_editor.mjs` (step 3f: anchors 3 → 5, 2 routing calls). **Fix idea:** when `handleDragStart` has claimed the mousedown (it already calls `e.preventDefault()`), let `handleMapClick` return early, for example by checking `e.defaultPrevented` or a "segment click handled" flag. Alternatively, drop one of the two paths. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Member

Fixed in batch PR #72 (deploy 5577c715), live since 2026-11-05 ~22:10 CET in wanderer-web:deploy-5577c715 (homelab-flux #857). Verified with the live e2e suite and acceptance re-runs as claude_test.

🤖 Generated with Claude Code

Fixed in batch PR #72 (`deploy` 5577c715), live since 2026-11-05 ~22:10 CET in `wanderer-web:deploy-5577c715` (homelab-flux #857). Verified with the live e2e suite and acceptance re-runs as `claude_test`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
public/wanderer#69
No description provided.