Fix dragend: update waypoint through proxy, not stale closure reference

This commit is contained in:
Davide Scaini
2026-05-13 22:47:42 +02:00
parent db15e6f7ed
commit df9ec3141c
+5 -3
View File
@@ -75,9 +75,11 @@
const wp = { lng, lat, marker }; const wp = { lng, lat, marker };
marker.on('dragend', () => { marker.on('dragend', () => {
const { lng: newLng, lat: newLat } = marker.getLngLat(); const { lng: newLng, lat: newLat } = marker.getLngLat();
wp.lng = newLng; const i = waypoints.findIndex(w => w.marker === marker);
wp.lat = newLat; if (i >= 0) {
waypoints = waypoints; // trigger reactivity waypoints[i].lng = newLng;
waypoints[i].lat = newLat;
}
fetchRoute(); fetchRoute();
}); });