Skip to content

feat: fix waypoint duplication on panel reopen & improve delete button enablement#377

Closed
ritgit24 wants to merge 5 commits intovalhalla:masterfrom
ritgit24:valhalla-waypoint-fixes
Closed

feat: fix waypoint duplication on panel reopen & improve delete button enablement#377
ritgit24 wants to merge 5 commits intovalhalla:masterfrom
ritgit24:valhalla-waypoint-fixes

Conversation

@ritgit24
Copy link

Closes #270 & #365

🛠️ Fixes Issue

  • Waypoints piling up on sidebar upon closing and reopening : Opening/closing left panel repeatedly appended empty waypoints, causing duplicates.
  • Wrong Delete Waypoint enablement : Delete button on a waypoint was clickable even when that waypoint had no selected geolocation , if atleast one other waypoint was selected with a location.

Both the issues were potentially causing bad UX.

👨‍💻 Changes proposed

  • use-directions-queries.ts : Ensuring waypoint slots exist before writing placeholders (prevents duplicated waypoints on sidebar reopen) by making permalink reverse‑geocode idempotent.

    • I feel we could have even removed the add empty waypoint functionality from the permalink parsing since the store remains independent of the component mount(which caused the error after all) but instead implemented that an empty waypoint will only be added if the length of store is lesser than what the permalink gives , just to be on the safer side.
  • waypoint-item.tsx : Only enable per‑waypoint Delete when that waypoint’s geocodeResults contains a selected result.

Test Updates

  • waypoint-item.spec.tsx , waypoints.spec.tsx : To align mocks/expectations with new behavior for the UI , and testing the geocode result handling

📷 Screenshots

Screenshot 2026-03-15 153835

@ritgit24 ritgit24 marked this pull request as ready for review March 15, 2026 11:06
Copilot AI review requested due to automatic review settings March 15, 2026 11:06
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates waypoint handling for directions permalink loading and adjusts waypoint removal behavior/tests.

Changes:

  • Expand directions waypoint list during permalink reverse-geocoding when indices exceed current waypoint count.
  • Change “remove waypoint” button disablement logic to depend on geocode selection state.
  • Update unit test mocks to include selected geocode results.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
src/hooks/use-directions-queries.ts Adjusts permalink reverse-geocode flow to add missing waypoints before setting placeholders.
src/components/isochrones/waypoints.spec.tsx Updates mocked geocodeResults in isochrones waypoint tests.
src/components/directions/waypoints/waypoint-item.tsx Changes remove-button disabled logic for directions waypoints.
src/components/directions/waypoints/waypoint-item.spec.tsx Updates waypoint test mock data to include selected flag.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +154 to +162
const currentLen = useDirectionsStore.getState().waypoints.length;
if (index >= currentLen) {
const toAdd = index - currentLen + 1;
for (let i = 0; i < toAdd; i++)
{
addEmptyWaypointToEnd();
}
}
}
Comment on lines +119 to +120
disabled={
!geocodeResults?.some((r) => r.selected)}
Comment on lines +33 to +35
{ selected: true, sourcelnglat: [13.4, 52.5] } ,
{ selected: true, sourcelnglat: [20.6, 39.1] } ,
{ selected: true, sourcelnglat: [29.7, 41.2] } ,
userInput: 'Berlin',
geocodeResults: [
{ title: 'Berlin, Germany', addressindex: 0, lngLat: [13.4, 52.5] },
{ title: 'Berlin, Germany', addressindex: 0, lngLat: [13.4, 52.5], selected: true },
@nilsnolde
Copy link
Member

closing due to not adhering to our gsoc guidelines

@nilsnolde nilsnolde closed this Mar 16, 2026
@ritgit24
Copy link
Author

closing due to not adhering to our gsoc guidelines

Sorry for any mistakes I may have made. I did spend a lot of time on this PR, carefully testing and verifying potential issues, and I also took clear note of the guidelines while preparing it. I would be very grateful if you could specify which guideline I didn’t adhere to .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

make the waypoint experience better by improving enabled/disabled logic

3 participants