Skip to content

fix: Navigate button silently fails for search results and drag-moved pins #173

@jasoneplumb

Description

@jasoneplumb

Symptoms

The "Navigate" button in the geocode-bar (next to Copy) silently does nothing in two flows:

  1. Search → Go to location: tap a search result's "Go to location" → bar shows → tap Navigate → nothing happens.
  2. Long-press, then drag the pin: long-press to drop a pin → drag to a new location → bar updates → tap Navigate → starts navigation to the original drop location, not the dragged location.

(Long-press without a subsequent drag works correctly.)

Root cause

currentPinLatLng is captured via a pinLayer.on('layeradd') listener. layeradd only fires when a new layer is added to the group:

  • Search Go to location: the handler calls pinLayer.clearLayers() and never adds a new pin → currentPinLatLng stays null (or worse, holds the value from the previous long-press) → click silently returns.
  • Pin drag: the marker moves but isn't re-added → layeradd doesn't fire → currentPinLatLng keeps the original drop location.

Fix

Thread the destination L.LatLng through showGeocodeBar(label, copyText, latlng). Set currentPinLatLng inside that function — showGeocodeBar is the single setter that all three flows (search, long-press, drag) already converge on. Remove the unreliable layeradd listener.

Also add a defensive toast ("No destination set") instead of the silent return, so any future regression surfaces visibly.

Acceptance

  • Search → Go to location → Navigate: starts routing to the search result
  • Long-press → Navigate: starts routing to the pin
  • Long-press → drag pin → Navigate: starts routing to the dragged location
  • Tap Navigate when no destination is set: "No destination set" toast
  • npm run type-check && npm run lint && npm test clean

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Critical — fix immediatelybugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions