Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dropdown suggestions when reversing origin and destination #246

Merged
merged 2 commits into from
Jul 14, 2020

Conversation

malwoodsantoro
Copy link
Contributor

@malwoodsantoro malwoodsantoro commented Apr 24, 2020

Fixes #245

With the current behavior, when reversing origin and destination, dropdown suggestions are displayed again which leads to a confusing UI.

reverse-fix2

Proposed behavior simply reverses the points (and step-by-step directions) and hides suggestions when reversing.

reverse-fix1

Copy link

@ryanhamley ryanhamley left a comment

Choose a reason for hiding this comment

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

Looks fine to me. If suggestions is only ever length 1, then we could simplify the logic by removing the for loop but it's not a huge deal

@@ -244,6 +244,10 @@ export function reverse() {
if (state.destination.geometry) dispatch(originPoint(state.destination.geometry.coordinates));
if (state.origin.geometry) dispatch(destinationPoint(state.origin.geometry.coordinates));
if (state.origin.geometry && state.destination.geometry) dispatch(fetchDirections());
const suggestions = document.getElementsByClassName("suggestions");
for (var i = 0; i < suggestions.length; i++) {

Choose a reason for hiding this comment

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

is it possible for suggestions to have more than one element in the array?

@malwoodsantoro malwoodsantoro merged commit 7fa85ae into master Jul 14, 2020
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.

Changing directions should honor the points already in Origin and Destination
2 participants