mapbox / mapbox/mapbox-gl-directions

Error thrown when trying to swap departure and arrival

Open
#296 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

auto-triaged bug
Dominant language
JavaScript
Stars
255
Forks
130
PR merge metrics
No merged PRs in 30d

Description

If you try to swap the depart location with the arrival you get the following error thrown:
```
mapbox-gl-directions.js:7626 Uncaught TypeError: Cannot read properties of undefined (reading 'coordinates') at HTMLButtonElement. (mapbox-gl-directions.js:7626:68)
```

This would be great to handle this case gracefully. In some cases this can result in an error message being thrown at the user (which depends on the specifics of the deployment) which isn't very friendly. I think this is something that needs to be handled at the component level with a conditional to check if the boxes are empty or not.

Actually, when only, say, the departure is set, and you hit the "swap" button to set it as arrival, the same error is thrown and the departure gets duplicated instead of swapped. This is rather unexpected. As a user you'd expect the box content to swap and thus the departure to become empty and the arrival box to get the former "departure" value.

Happy to send screens if needed, but the bug should be reproducible when one of the directions boxes (e.g. the departure) is unset and when you then try to swap the values with the double arrow symbol (if no error gets thrown on the UI, open the web console and an error as the one pasted above should show up).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with one or both direction boxes empty by using the double-arrow swap button, then inspect mapbox-gl-directions.js around line 7626 and the swap-button handling. Done means swapping populated values without duplication, leaving the previously populated box empty when only one value is set, and avoiding the undefined coordinates error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.